I agree that the maximum value of Ulong is 2^32-1 but there are 2^32 values including zero, so we must divide by 2^32. This is why we have floating point returns of [0,1) since (2^32-1)/2^32 < 1.MrSwiss wrote:It isn't: 2^32 but: 2^32-1
If you look at Greg Lyon's FB version of the Mersenne Twister C code we have
Code: Select all
'/* generates a random number on [0,1)-real-interval */
'double genrand_real2(void)
'{
' return genrand_int32()*(1.0/4294967296.0);
' /* divided by 2^32 */
'}
This is from a recent paper, Middle Square Weyl Sequence RNG by Bernard Widynski, where he writes "We can demonstrate uniformity by showing that the probability of any given output is 1/2^32. That is because there are 2^32 possible outcomes.
I could go on but you will find that all 32-bit generators divide by 2^32 for a floating-point value.
Paul Doe uses
Code: Select all
'' To get a value in the 0 <= n < 1 range
? ( mswsrnd() / ulongMax )
Code: Select all
const _
ulongMax => culng( -1 ), _
ulongIntMax => culngint( -1 )
No comment.(Btw. if you feel the need to get angry at someone, taget yourself this time.)