Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Number Generator

Status
Not open for further replies.

SiouxCityElvis

Programmer
Jun 6, 2003
228
US
Anyone ever created a Random Number Generator?
I'm using RMCOBOL-85 version 8 on Linux. I thought maybe the newest release might have a Random Number Generator sub-program(C$name), but I don't think so...

Thanks.
-David
 
You may want to ask your "vendor of choice" (listening Tom) exactly WHEN (if ever) they plan on implementing the Intrinsic Functions module which has been a part of the REQUIRED "High-Level" FIPS COBOL definition since 1990 (or so) and has been an optional part of the High-level ISO/ANSI Standards since then.

It is a REQUIRED part of the ANSI/ISO 2002 COBOL Standard

...

And it includes a RANDOM function (which is only PSEUDO-random - if you don't "vary" the seed value)
 
In any multi-tasking system such as Windows NTtm or Unix, the low-order bits of the time clock make and excellent random seed.
 
Bill,

Actually, David is the first customer in my recollection that has asked for RANDOM. Our customer base has been notably quite about any intrinsic functions; they have other concerns that more directly impact the marketability of their software. I have had a discussion with the compiler gurus about REVERSED, my personal favorite. [smile]



Tom Morrison
 
I saw some stuff out there for different types of COBOL on the web about Random Number generators i.e. "seed", "pseudo-random" as mentioned above by WMK.

Seems simple to do in Java. Just curious why the Intrinsic Functions module or other sub-program (C$...) does not include random number generation in RM-COBOL. Random Number generation seems to be a pretty common necessity. Learned about it in classes back in my school days and have seen it used in Java in other work places.

On a more positive note, I did get to use C$DELAY yesterday and was happy about its results!
I'll check that link out. Thanks.

Webrabbit:
What's the efficiency of using the low order bits of the system's clock for the seed in a random number? What if you have 2 transactions, for example, hitting your application one right after the other within milliseconds of each other? For each you need a distinct random number generated. Since they are within milliseconds of each other, wouldn't you end up with the same random number on each?
 
Tom,
Do you know how to access the Linux/Unix clock's lower bit values as suggested by Webrabbit above from my COBOL program?

I used that link you suggested. It has various Math functions in it including the RN Generator, but I'm required to send it a value for setting the format value of the seed variable to be used in the Random function later.

So, in order to make that seed a random number, I thought maybe Webrabbit's suggestion would work.

Thanks.
-David
 
A common characteristic of pseudo-random number generators is the ability (necessity) to specify the initial seed value. Often, one wants random number sequences that may be reliably repeated!

I do not know, off the top of my head, what system call returns the system clock.

May I ask...what are you trying to accomplish with a random number?

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top