Skip to content

Conversation

@rfourquet
Copy link
Member

show for MersenneTwister outputs valid input syntax, by dumping a condensed state, which is used by the constructor to reconstruct the real state.

In the case where rand is called on an instance which is then jumped, the output state was triggering an assertion error when parsed back; this assertion was wrong, so remove it. For example:

julia> m = MersenneTwister(123); rand(m); Random.jump!(m, big(10)^20)
MersenneTwister(0xf80cc98..., 0xea7a7d..., 100000000000000000000, 1002)

julia> MersenneTwister(0xf80cc98..., 0xea7a7d..., 100000000000000000000, 1002)
ERROR: AssertionError: adv == 0
Stacktrace:
[...]

`show` for `MersenneTwister` outputs valid input syntax, by dumping
a condensed state, which can be used to reconstruct the real state.

In the case where an rng is used, then jumped, the output state
was triggering an assertion error when parsed back; this assertion
was wrong, so remove it. For example:
```
julia> m = MersenneTwister(123); rand(m); Random.jump!(m, big(10)^20)
MersenneTwister(0xf80cc98..., 0xea7a7d..., 100000000000000000000, 1002)

julia> MersenneTwister(0xf80cc98..., 0xea7a7d..., 100000000000000000000, 1002)
ERROR: AssertionError: adv == 0
Stacktrace:
[...]
```
@rfourquet rfourquet added randomness Random number generation and the Random stdlib bugfix This change fixes an existing bug labels Nov 26, 2025
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 randomness Random number generation and the Random stdlib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants