Author: Robert Sample
Posted: Mon Aug 29, 2016 6:28 pm (GMT 5.5)
1. You need to understand "random" -- your point (a) completely contradicts the idea of randomness.
2. Computers do not generate mathematically random numbers -- what you get is a sequence of pseudorandom numbers. For IBM's Enterprise COBOL, from any given starting seed, you get over 2 billion values before they start repeating.
3. Read carefully the description of function RANDOM in the Enterprise COBOL Language Reference manual - it tells you several important things to know (such as the returned value is in the range of zero to one so you will have to scale it, and that you need to provide an initial seed value followed by no arguments; if you don't provide a seed the sequence will ALWAYS be the same).
4. How far back does the "requirement" for uniqueness go? If you are saying that there can never be a duplicate, then you might as well give up now as a pseudorandom sequence will repeat, sooner or later -- period. If not, you need to be clear about how many unique values are required before a duplicate could occur (a duplicate may not occur for a long time, but you still need to know how many unique values are required).
Oh, and terminology is critical in IT where similar terms may mean very different things. COBOL does not have "strings" as used in other languages -- that is, variables whose length varies at run time. COBOL allows, in very limited cases, variable length variables but unlike a Java string these variables are NOT required to be terminated with a \0 (or LOW-VALUE in COBOL terms).
_________________
TANSTAAFL
The first rule of code reuse is that the code needs to be worth re-using.
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth
Posted: Mon Aug 29, 2016 6:28 pm (GMT 5.5)
1. You need to understand "random" -- your point (a) completely contradicts the idea of randomness.
2. Computers do not generate mathematically random numbers -- what you get is a sequence of pseudorandom numbers. For IBM's Enterprise COBOL, from any given starting seed, you get over 2 billion values before they start repeating.
3. Read carefully the description of function RANDOM in the Enterprise COBOL Language Reference manual - it tells you several important things to know (such as the returned value is in the range of zero to one so you will have to scale it, and that you need to provide an initial seed value followed by no arguments; if you don't provide a seed the sequence will ALWAYS be the same).
4. How far back does the "requirement" for uniqueness go? If you are saying that there can never be a duplicate, then you might as well give up now as a pseudorandom sequence will repeat, sooner or later -- period. If not, you need to be clear about how many unique values are required before a duplicate could occur (a duplicate may not occur for a long time, but you still need to know how many unique values are required).
Oh, and terminology is critical in IT where similar terms may mean very different things. COBOL does not have "strings" as used in other languages -- that is, variables whose length varies at run time. COBOL allows, in very limited cases, variable length variables but unlike a Java string these variables are NOT required to be terminated with a \0 (or LOW-VALUE in COBOL terms).
_________________
TANSTAAFL
The first rule of code reuse is that the code needs to be worth re-using.
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth