Introducing the Colour Maximite 2

Author Message

Joined: 11/12/2012
Location: United Kingdom
Posts: 6382
Posted: 10:45am 08 May 2020      

  Quote  I am surprised that there is no facility to seed a random number. It could be useful when trying to get repeatable results for testing (please don't ask for an example right now).

This is really trivial

Try the attached - takes 75 microseconds to run on the CMM2, x is the seed

function pseudo() as float
 static integer x=7
 static integer a=1103515245
 static integer c=12345
 static integer m=2^31
 x=(a * x + c) mod m
 pseudo = x/m
end function

and here is the distribution analysis

Edited 2020-05-08 20:52 by matherp