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: Vince Coen
Subject: Re: [open-cobol-list] How to use RANDOM function.
Date: Wed, 10 Nov 2010 22:29:27 +0000
User-agent: KMail/1.13.3 (Linux/2.6.33.7-server-2mnb; KDE/4.4.3; i686; ; )

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



reply via email to

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