Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Usage of RANDOM function in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Sun Nov 05, 2006 7:37 pm    Post subject: Usage of RANDOM function in COBOL
Reply with quote

Hi,
Has anybody used RANDOM function in COBOl?

If so,Can you please explain me the function with a piece of batch code?

I went through the manual but it is easy to understand with a piece of code.

Thanks in Advance,

Thanks,
Muthuvel.
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Nov 06, 2006 3:04 am    Post subject: Re: Usage of RANDOM function in COBOL
Reply with quote

The random function takes a non-negative integer argument and returns a decimal number. The integer argument is optional. It is the seed for a pseudo-random mathematical process, that determines the function’s first returned number. In computer languages, all random processes are in fact long, repeating series of numbers that appear to be random. A well-chosen process repeats only after billions of values, so it is a practical source of random numbers, even if it is not a theoretically pure one. If you supply the random function with an argument, it will generate the same sequence of numbers. Without the argument, the random function generates the next number in its sequence.

Quote:
I went through the manual but it is easy to understand with a piece of code.

Could you put the manual link describing RANDOM FUNCTION.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Wed Nov 08, 2006 2:32 pm    Post subject: Re: Usage of RANDOM function in COBOL
Reply with quote

Priyesh,
This is the lengthy stuff :? which i got for RANDOM function in COBOL.

The RANDOM function returns a numeric value that is a pseudorandom number
from a rectangular distribution.

The function type is numeric.

+--- Format -------------------------------------------------------------+
| |
| >>--FUNCTION RANDOM------------------------------------------------->< |
| +-(argument-1)-+ |
| |
+------------------------------------------------------------------------+
argument-1
If argument-1 is specified, it must be zero or a positive integer, up
to and including (10**18)-1 which is the maximum value that can be
specified in a PIC9(18) fixed item; however, only those in the range
from zero up to and including 2,147,483,645 will yield a distinct
sequence of pseudorandom numbers.

If a subsequent reference specifies argument-1, a new sequence of
pseudorandom numbers is started.

If the first reference to this function in the run unit does not specify
argument-1, the seed value used will be zero.

In each case, subsequent references without specifying argument-1 return
the next number in the current sequence.

The returned value is exclusively between zero and one.

For a given seed value, the sequence of pseudorandom numbers will always be the same.



Regards,
Muthuvel.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Dec 01, 2006 6:54 am    Post subject: Re: Usage of RANDOM function in COBOL
Reply with quote

muthuvel,

I know this is a late post, and you probably have your solution. But I just posted some code that uses tha RANDOM function. So if you still need it:

RANDOM FUNCTION

Dave
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Fri Dec 01, 2006 10:30 am    Post subject: Re: Usage of RANDOM function in COBOL
Reply with quote

Dave,
Thanks!!!!
Though it was a late reply,Thanks for the concern.

Thanks,
Muthuvel
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us