[Haskell-beginners] Generating Random Float
Daniel Fischer
daniel.is.fischer at web.de
Fri Apr 23 09:46:53 EDT 2010
Am Freitag 23 April 2010 15:33:43 schrieb Giorgio Stefanoni:
>
> However, if I try to generate a Float instead, I always get an
> Arithmetic Overflow error that I can not understand.
>
> Code:
>
> rand :: IO Float
> rand = do r <- newStdGen
> let (x1, r2) = randomR (0.0::Float,1.0::Float) r
> print x1
> return x1
>
Works here. And it should.
Must be the implementation you use, though I can't imagine why it would
screw up on this.
>
>
> Do you have any clue why this happens?
>
> Thanks in advance,
More information about the Beginners
mailing list