Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug with rand(::MersenneTwister, ::UInt128) #37808

Merged
merged 1 commit into from
Oct 3, 2020

Conversation

rfourquet
Copy link
Member

@rfourquet rfourquet commented Sep 29, 2020

Generation of UInt64 and UInt128 share the same cache, but the routine
handling generation of UInt128 was not fully aknowledging the sharing.
This leads to situations like:

julia> m = MersenneTwister(0); rand(m, UInt64); rand(m, UInt128)
0x79ed9db9ec79a6a019c5f638a776ab3c

julia> rand(m, UInt64)
0x19c5f638a776ab3c

These values aren't independent enough!

Generation of UInt64 and UInt128 share the same cache, but the routine
handling generation of UInt128 was not fully aknowledging the sharing.
This leads to situations like:

```
julia> m = MersenneTwister(0); rand(m, UInt64); rand(m, UInt128)
0x79ed9db9ec79a6a019c5f638a776ab3c

julia> rand(m, UInt64)
0x19c5f638a776ab3c
```
Indeed, these values aren't independent enough :(
@rfourquet rfourquet added embarrassing-bugfix Whoops! randomness Random number generation and the Random stdlib bugfix This change fixes an existing bug labels Sep 29, 2020
@rfourquet rfourquet merged commit 9392bbe into master Oct 3, 2020
@rfourquet rfourquet deleted the rf/rand/fix-Int128-Int-aliasing branch October 3, 2020 14:15
krrutkow added a commit to krrutkow/CBinding.jl that referenced this pull request Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug embarrassing-bugfix Whoops! randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant