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

possible issue with u64->f64 conversion in rand/float.rs #426

Closed
jasondark opened this issue May 4, 2018 · 1 comment
Closed

possible issue with u64->f64 conversion in rand/float.rs #426

jasondark opened this issue May 4, 2018 · 1 comment

Comments

@jasondark
Copy link

The function into_float_with_exponent implements the standard bit-pattern hack to grab the 53 significant bits and subtract 1. However, according to http://xoshiro.di.unimi.it/ (see section "Generating uniform doubles in the unit interval") this halves the range of possible values by always resulting a least significant bit of zero. It is proposed to just use the more straight-forward (myint>>11) as f64 / (1u64 << 53) as f64 instead.

@pitdicker
Copy link
Contributor

@jasondark Thank you for opening this issue. Just a couple of days late for the party, see #416 which had similar concerns.

In a way both methods are imperfect, as floats do not have a fixed precision. But we changed the default method to the traditional multiply approach in #420.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants