Modified RealRandom.spin
Jorge P
Posts: 385
Hi all, I thought this modification to RealRandom.spin would be usefull to alot of you who require random numbers within a certain range. This is more an addition to the origional driver than a modification.
The new function "RealRandom.randomMax(nMax)" will return a number between 0 and nMax-1. without slowing things down too much.
I have included a demo with the attached zip. Hope you enjoy.
Jorge
The new function "RealRandom.randomMax(nMax)" will return a number between 0 and nMax-1. without slowing things down too much.
I have included a demo with the attached zip. Hope you enjoy.
Jorge
Comments
Jorge, BTW, you can eliminate your CASE statement completely by using the result of the >| operator to compute the required shift amount.
-Phil
E,g if you want a random number between 10 and 20 ?
In this case, couldn't you simply specify maximum of 10, and add 10 to the result? That would get you to the correct range.