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

Some std::f32 constants are actually f64s #11537

Closed
zhanrnl opened this issue Jan 14, 2014 · 4 comments · Fixed by #13710
Closed

Some std::f32 constants are actually f64s #11537

zhanrnl opened this issue Jan 14, 2014 · 4 comments · Fixed by #13710

Comments

@zhanrnl
Copy link

zhanrnl commented Jan 14, 2014

std::f32::MAX_VALUE, std::f32::MIN_VALUE, and std::f32::EPSILON are all actually f64s, not f32s as expected. FLT_MAX and FLT_MIN in C are all floats, not doubles, for example. If this is intentional, it's very confusing to me why any constants in the std::f32 module should be f64s, and probably should be explained in the documentation.

@adrientetar
Copy link
Contributor

MAX_VALUE isn't defined in f32.rs. I don't know how it works but it must be kinda redirected to f64.

@zhanrnl
Copy link
Author

zhanrnl commented Jan 14, 2014

Unless I'm completely misunderstanding something, I think it is. Interestingly, the source references issue #1433, which doesn't seem related.

@huonw
Copy link
Member

huonw commented Jan 14, 2014

@zhanrnl #1433 is related (to the constants themselves, but not to this issue), because the statics should be written in hex to guarantee that they have the exactly correct value.

@aturon
Copy link
Member

aturon commented Apr 22, 2014

Note: this issue and issue 13297 should be resolved together.

aturon added a commit to aturon/rust that referenced this issue Apr 23, 2014
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.
bors added a commit that referenced this issue Apr 24, 2014
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.
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 16, 2023
new lint: `repeat_vec_with_capacity`

Closes rust-lang#11537

[Lint description](https://github.com/y21/rust-clippy/blob/repeat_vec_with_capacity/clippy_lints/src/repeat_vec_with_capacity.rs#L14) should explain this PR :)

changelog: new lint: `repeat_vec_with_capacity`
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

Successfully merging a pull request may close this issue.

4 participants