[Haskell] trouble with the random number generator

2010-04-08 Thread Garrett Mitchener
Hi, I'm having some trouble with the standard random number generator. I re-implemented it for speed, but the same problem seems to be present in the original. The problem I'm having is in the generation of a random Double. If you go down to the function randomIvalDouble in Random.hs (and I'm

Re: [Haskell] trouble with the random number generator

2010-04-08 Thread Ian Lynagh
On Thu, Apr 08, 2010 at 10:20:25AM -0400, Garrett Mitchener wrote: 1/2 - 2^31/(2^32-1) = 2^31( 1/2^32 - 1/(2^32-1) ) = -1.164e-10 0 which is outside the required range. Yup, looks like a bug to me. Even if it were fixed so that the maths seemed to show no bug, I wouldn't be surprised if