Author: Robert Sample
Posted: Sat Sep 03, 2016 12:54 am (GMT 5.5)
The Enterprise COBOL RANDOM intrinsic function is an interesting function. It returns COMP-1 or COMP-2 (short floating point or long floating point) values. The long floating point values are NOT the same as the short floating point values; sometimes there is a difference of several digits in the last place of the short floating point value, compared to the same number of digits of the long floating point.
Using a seed value of zero and short floating point values (32-bit), the sequence generated a duplicate in the 18,823,902nd value in the sequence, running on a 5.1.1 compiler. To generate a full non-repeating sequence appears to require a 64-bit (long floating point) variable to hold the result. This duplicate took 13.2 seconds of CPU and 1.4 minutes elapsed time to find. Using 18823902 as the seed value, the first duplicate occurred at call 44,221,983 to RANDOM; this took 32 seconds of CPU time and 3.1 minutes elapsed.
_________________
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: Sat Sep 03, 2016 12:54 am (GMT 5.5)
The Enterprise COBOL RANDOM intrinsic function is an interesting function. It returns COMP-1 or COMP-2 (short floating point or long floating point) values. The long floating point values are NOT the same as the short floating point values; sometimes there is a difference of several digits in the last place of the short floating point value, compared to the same number of digits of the long floating point.
Using a seed value of zero and short floating point values (32-bit), the sequence generated a duplicate in the 18,823,902nd value in the sequence, running on a 5.1.1 compiler. To generate a full non-repeating sequence appears to require a 64-bit (long floating point) variable to hold the result. This duplicate took 13.2 seconds of CPU and 1.4 minutes elapsed time to find. Using 18823902 as the seed value, the first duplicate occurred at call 44,221,983 to RANDOM; this took 32 seconds of CPU time and 3.1 minutes elapsed.
_________________
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