Skip to content

[email protected] randomSeeded gives different results for some seeds vs 0.1.1 #6688

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

Closed
lionel-rowe opened this issue May 28, 2025 · 1 comment · Fixed by #6689
Closed
Labels
bug Something isn't working needs triage

Comments

@lionel-rowe
Copy link
Contributor

Describe the bug

[email protected] randomSeeded gives different results for some seeds (not covered by current tests). cc @kt3k

Steps to Reproduce

for (const v of ['0.1.0', '0.1.1']) {
    const { randomSeeded } = await import(`jsr:@std/random@${v}`)
    const seed = 6552010792480112863n
    console.log(`${v}: ${randomSeeded(seed)()}`)
}

Expected

0.1.0: 0.6705842935480177
0.1.1: 0.6705842935480177

Actual

0.1.0: 0.6705842935480177
0.1.1: 0.10435933456756175

If the seed is 6552010792480112862n instead of 6552010792480112863n, the results are the same.

The 0.1.0 results are consistent with rust rand.

Environment

[email protected]

@lionel-rowe
Copy link
Contributor Author

Cause: increment was being ORed with 1 upon setting only in the constructor, not when it was used to move away from initial value prior to being initialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant