jhunt
08-17-2009, 07:17 AM
Hello, I'm attempting to generate a random double, but I'm having an issue.
Here is the forumla I am using to generate the double:
dblTemp = Int((dblUBound - dblLBound + 1) * Rnd + dblLBound)
A test case is failing, where dblUbound = 4294967295 and dblLBound = 0. In this case the above forumla reliably returns a double where the least signifigant byte is zero.
In the routine that tests for unusual patterns in the random numbers, I have:
dblTemp - (fix(dblTemp / 256) * 256)
to display the LSB (since MOD doesn't work with doubles). This formula passes the a unit test properly.
If I use this formula to evaulate the numbers returned (or any forumla) the LSB is zero.
Even if I break it down further:
dblTemp = dblUBound * Rnd
Running it through my MOD forumla relaibly produces an LSB of 255, and of course a decimal component.
So, just a sanity check here.. is somthing in my math very wrong, or is VB failing ye olde basic mathe (or ye olde randome number generation)
Thanks!
Here is the forumla I am using to generate the double:
dblTemp = Int((dblUBound - dblLBound + 1) * Rnd + dblLBound)
A test case is failing, where dblUbound = 4294967295 and dblLBound = 0. In this case the above forumla reliably returns a double where the least signifigant byte is zero.
In the routine that tests for unusual patterns in the random numbers, I have:
dblTemp - (fix(dblTemp / 256) * 256)
to display the LSB (since MOD doesn't work with doubles). This formula passes the a unit test properly.
If I use this formula to evaulate the numbers returned (or any forumla) the LSB is zero.
Even if I break it down further:
dblTemp = dblUBound * Rnd
Running it through my MOD forumla relaibly produces an LSB of 255, and of course a decimal component.
So, just a sanity check here.. is somthing in my math very wrong, or is VB failing ye olde basic mathe (or ye olde randome number generation)
Thanks!