-
Notifications
You must be signed in to change notification settings - Fork 13k
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
std::f32 declares wrong mantissa length #13297
Comments
Ugh, many constants in |
CTFE isn't going to happen any time soon, and may not happen at all. They're not going to be possible to remove for a long time. |
There is a broader problem here: the
while
(In particular, Moreover,
while
Finally, the float types implement the Does anyone know if these discrepancies, which affect both @bjz, care to weigh in? |
Note: this issue and issue 11537 should be resolved together. |
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrent, even when the values were correct. Closes rust-lang#13297. Closes rust-lang#11537.
Some of the constant values in std::f32 were incorrectly copied from std::f64. More broadly, both modules defined their constants redundantly in two places, which is what led to the bug. Moreover, the specs for some of the constants were incorrect, even when the values were correct. Closes #13297. Closes #11537.
Follow-up on issue rust-lang#13297 and PR rust-lang#13710. Instead of following the (confusing) C/C++ approach of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and in the Float trait, `min_pos_value`) to represent this number. This patch also removes a few remaining redundantly-defined constants that were missed last time around.
Follow-up on issue #13297 and PR #13710. Instead of following the (confusing) C/C++ approach of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and in the Float trait, `min_pos_value`) to represent this number. This patch also removes a few remaining redundantly-defined constants that were missed last time around.
Hate to dig up a 9 year old issue, but it seems the wrong mantissa is still present. It is the first result on google when you search for f32 mantissa. https://doc.rust-lang.org/std/primitive.f32.html#associatedconstant.MANTISSA_DIGITS Should this be fixed or removed? |
@cgbur the value has been corrected to 24. Is that wrong? |
I understand the confusion now; the value includes the implicit bit. I was approaching this from the standpoint of bit-shifting and was surprised by the inclusion. In most writing I've seen, it is described as 23, or 24 including the implicit bit. A brief note in the documentation to clarify this might be helpful in case I’m not the only one who made the mistake. |
static pub MANTISSA_DIGITS: uint = 53u;
I guess that should be 24. Or is there some reasoning behind it that I don't see?
As well as
std::f32::DIGITS
which should probably be 6 instead of 15.The text was updated successfully, but these errors were encountered: