|
From: Leif Svalgaard <leif@leif.org> > The following code will work on any COBOL compiler: > start by putting a SEED value in RANDOM-SEED. This could be time of day > or anything else you like. Then each time you PERFORM RANDOM-FUNCTION > the data-item RANDOM-RESULT will contain a new pseudo-random value > between 0 and 1. To get an integer X between 1 and 47 (say): > COMPUTE X = RANDOM-RESULT * 47 + 0.5 > you should actually use ROUNDED to get a correct result: COMPUTE X ROUNDED = RANDOM-RESULT * 47 + 0.5 HTH Leif
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.