The COBOL RANDOM
function documentation doesn't give sufficient information on the range of accepted values for argument-1
.
Perhaps someone can shed light on my following questions:
- What range of seed values is accepted?
- How are values treated that are exceeding the allowed range?
- Are they truncated?
- Are only the lower bits used?
- Or the upper bits?
- Are the leftmost digits used?
- Or the rightmost?
- How many of them?
- Is a
MOD
function applied to the seed value?
In short:
Is there a specification in the COBOL standard defining which digits of a value like 01 myRandomSeed PIC 9(50).
are being used?
For the COBOL standard have a look at the current draft standard (the files available there vary depending on the current state of the committee work), which has the
RANDOM
function under "15 intrinsic functions".The format is:
With the rules that the optional argument-1 shall be of class numeric and either be zero or a positive integer.
For the returned value: