|
Oooh, I missed that. Very nice! I'll have to remember that one! randomreturn = ((Max_Range - 1) / Random * Range) + 1 Regards, Jim Langston Me transmitte sursum, Caledoni! Chris Rehm wrote: > > His message did show that he was using 32768 as the divisor. So, > he'll get a value between 0/32768 and 32767/32768. > This gives me a chance to use the only thing I've ever liked about > Windows, the calculator it comes with. So he'll get a value ranging from > 0 to .999969482421875 (barring any typos on my part). > That should give as flat a distribution across his own range as the > generator has across its own range, provided he does not wish to > generate numbers larger than 32767. If he does, he will need a different > random number generator or to append multiple results from this > generator bitwise and then divide by the new range. > > Jim Langston wrote: > > > Chris, Paul, > > > > That being said, Paul's solution can still be screwed, depending > > on how the system is adjusting for math. One out of 32767 times > > it will return a value 1 greater than his range. > > > > For a range 1 to 10 (normal return): > > 32766 / 32767 = 0.999969481 * 10 = 9.99969481. Truncate returns > > [snip] s/b 32766/32768 > > > Regards, > > > > Jim Langston > > > -- > > Chris Rehm > <mailto:javadisciple@earthlink.net> -- +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.