-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
last bit of random f32 and f64 is not random #315
Comments
Thanks @dhardy, if there is a high precision rng in the works for floats then that solves my issue, and I will just keep in mind the current limitations. |
Good to hear. The current |
@cake4289 You can use the higher precision floating point methods with May I ask you how you noticed the change? If you depend on some bits of a floating point value to be 1 or 0 with a 50% chance, and without patterns, there may be some trouble. Maybe I/we can suggest something if we see how you are using it...
With the |
The following "random" boolean generator will always print
false
:Note that this is on master. On the latest release, the last bit is always 0. This is because of an algorithm change that changes the last bit for numbers between 0.5 and 1 by subtracting
EPSILON / 2.0
.For smaller numbers it is perhaps ok that there are gaps, since then the possible random values are evenly spaced. But it seems wrong to miss off 1 bit of precision for all floating point values.
The text was updated successfully, but these errors were encountered: