Re: Anyone need a random number generator?
Rick Fochtman <[email protected]>
| Newsgroups | gmane.comp.emulators.turnkey-mvs |
|---|---|
| Message-ID | <[email protected]> |
-------------------------------<snip>------------------------------- > > > On Wed, Apr 28, 2010 at 3:03 PM, Ron Hudson <[email protected] > <mailto:hudson.ra%40gmail.com>> wrote: > > > > On Wed, Apr 28, 2010 at 12:39 PM, Rick Fochtman <[email protected] > <mailto:rfochtman%40ync.net>> wrote: > <<deleted>> > >> //FORT.SYSIN DD * > >> C RANDOM NUMBER GENERATOR > >> FUNCTION IRND(ISEED) > >> IY = IABS(MOD(1103515245 * ISEED + 12345,2**15)) > >> IRND = IY > >> RETURN > >> END > <<deleted>> > >> > >> (Given the math I see there, you might experience integer overflow > conditions in the first argument to the MOD function.) > > > > What can I do? I guess I need to user a 'larger' integer - What is > a good reference (there is a short overview > > on Jay Moseley's site but no detail like how to specify more bits... > > > The assembler equivalent should run (i.e. not overflow the registers), > not sure about how this particular compiler creates the machine > instructions. You will need to test by calling the routine and > logging the results. > ------------------------------------<unsnip>---------------------------------- Doing it in Assembler will not "use more bits". FORTH uses the full 32 bits of the 370 architecture. Since the value 1,103,515,245 is being multiplied by the ISEED parameter, the resultant value may easily exceed 32 bits. Perhaps even exceeding the 64 bits result of the multiply instruction. Then what? Rick