Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fiddling around with random #s and odds.
#18
Quote:RND used the OS's C runtime rand function until version 0.17 jun-30 unstable. The rand function in Windows' library has a granularity of just 15 bits, so probably it is unable of generating exactly 1234567. For comparison QB's RND has 24 bits granularity.

In the present version compiled from CVS you have a different RND depending on the -lang option passed in the command line of the compiler:
With -lang qb you have a RND mimicking exactly QB's generator.
With -lang fb (the default) you have a Mersenne Twister algorithm with 32 bits granularity.
With -lang deprecated it behaves as 0.16 version, using C runtime's rand

You have too a fourth "fast" random algorithm and a second argument to RANDOMIZE allowing to select the algorithm used...

So perhaps some of you updated to the CVS version, it would explain why you get 1234567. Or you are using the DOS or Linux version where the granularity of rand is 31 bits..

More in the wiki:
http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgRnd
1234567=(x*2000000)+1
x=1234566/2000000
x=0.617283
So you're saying that my version of FB is unable to generate 0.617283 because the RND function doesn't generate numbers to that precision?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply


Messages In This Thread
Fiddling around with random #s and odds. - by Anonymous - 01-08-2007, 06:30 PM
Fiddling around with random #s and odds. - by Dio - 01-09-2007, 02:15 AM
Fiddling around with random #s and odds. - by Dio - 01-10-2007, 01:50 AM
Fiddling around with random #s and odds. - by Neo - 01-10-2007, 07:40 PM
Fiddling around with random #s and odds. - by Zack - 01-12-2007, 08:57 AM
Fiddling around with random #s and odds. - by DrV - 01-14-2007, 02:14 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)