gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] How to use RANDOM function.


From: Michael
Subject: Re: [open-cobol-list] How to use RANDOM function.
Date: Wed, 10 Nov 2010 16:50:32 -0600
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

It would be nice when you use FUNCTION RANDOM with (0), that the function would actually get a new seed from the system timer to start a new sequence of pseudo-random numbers. Currently as far as I know, calling FUNCTION RANDOM with the value 0, or calling it without passing an argument at all, always resets the sequence of pseudo-random numbers to the same starting point.
The seed would a 16 or 32 bit integer?

Want truly random? Look at random.org where they get their numbers from random 
atmospheric noise.

Mike.

Vince Coen wrote:
On Wednesday 10 Nov 2010, John Culleton wrote:
I want to have a certain number randomly chosen every time a certain
program runs.

 I have this in WORKING-STORAGE:
        77  RANDUM PICTURE S9V9(10).
I have this statement:
COMPUTE RANDUM = FUNCTION RANDOM(0).
Every time I run the program the value of RANDUM is the same. If I
change the seed then I get a different number but that is repetitious
also. If I leave off the seed it acts as if the seed was zero.

I think you are misusing this function in regard to OC, form is:

Function returns a numeric value that is a pseudo-random number from a rectangular distribution. The type of this function is numeric.

function random (argument-1)

the returned value is grater than or equal to zero and less than 1. The domain of arg-1 values will yield distinct sequences of pseudo random numbers. [So far so good]. This subset includes the values from 0 through at least 32767.

[Taken from MF manual but the OC docs does not specify this]

1. Try just doing move function random (0) to randum and see what you get.

2. Suggest you also try using a pic of 9(5) (without the implied decimal placing and see what you get.
I'm saying this just in case OC does NOT stick to values 0 to 1.


Vince


------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list



reply via email to

[Prev in Thread] Current Thread [Next in Thread]