#1272: newStdGen returns the same value on successive calls
-------------------------------+--------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.8
Component: libraries/base | Version: 6.6
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Os: Unknown | Testcase:
Architecture: Unknown |
-------------------------------+--------------------------------------------
Changes (by igloo):
* component: Compiler => libraries/base
* milestone: => 6.8
Old description:
> It seems newStdGen only depends on the second, it should have better
> resolution and/or use /dev/random.
>
> Test program:
>
> import Random
> main = newStdGen >>= print
>
> compiled with ghc 6.6 or 6.7 (at some point in time)
> Running "date; ./random" gives:
>
> Thu Apr 12 10:51:54 CEST 2007
> 1938403181 6764
> Thu Apr 12 10:51:54 CEST 2007
> 1938403181 6764
> Thu Apr 12 10:51:55 CEST 2007
> 529729936 6762
> Thu Apr 12 10:51:55 CEST 2007
> 529729936 6762
> Thu Apr 12 10:51:56 CEST 2007
> 1023702766 6762
> Thu Apr 12 10:51:56 CEST 2007
> 1023702766 6762
> Thu Apr 12 10:52:03 CEST 2007
> 186545450 6762
> Thu Apr 12 10:52:04 CEST 2007
> 680518280 6762
> Thu Apr 12 10:52:04 CEST 2007
> 680518280 6762
New description:
It seems newStdGen only depends on the second, it should have better
resolution and/or use /dev/random.
Test program:
{{{
import Random
main = newStdGen >>= print
}}}
compiled with ghc 6.6 or 6.7 (at some point in time)
Running "date; ./random" gives:
{{{
Thu Apr 12 10:51:54 CEST 2007
1938403181 6764
Thu Apr 12 10:51:54 CEST 2007
1938403181 6764
Thu Apr 12 10:51:55 CEST 2007
529729936 6762
Thu Apr 12 10:51:55 CEST 2007
529729936 6762
Thu Apr 12 10:51:56 CEST 2007
1023702766 6762
Thu Apr 12 10:51:56 CEST 2007
1023702766 6762
Thu Apr 12 10:52:03 CEST 2007
186545450 6762
Thu Apr 12 10:52:04 CEST 2007
680518280 6762
Thu Apr 12 10:52:04 CEST 2007
680518280 6762
}}}
Comment:
I see no reason not to use the second component of TOD; it doesn't need a
type conversion or anything, and even if it is very low precision it won't
hurt to include it.
We have a small collection of Random bugs accumulating! Hopefully someone
will be able to give the library the once-over for 6.8.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1272>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs