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

Incorrect f32::NAN as u64/u128 conversion #75

Open
ghost opened this issue Sep 1, 2021 · 2 comments
Open

Incorrect f32::NAN as u64/u128 conversion #75

ghost opened this issue Sep 1, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Sep 1, 2021

The code generated for black_box(f32::NAN) as u64/u128 converts it to some junk, but correct result is 0. This happens only with f32::NAN and only when converted to u64/u128. Conversion into i64/i128 works fine, as well as conversions intou8, i8, ... u32,i32.

@antoyo antoyo added the bug Something isn't working label Oct 31, 2021
@antoyo
Copy link
Contributor

antoyo commented Feb 1, 2022

This is because gcc gives a negative NAN for 0.0 / 0.0.

Does Rust define that the sign of NAN should be positive?

Possibly relevant: rust-lang/rust#81261

@RalfJung
Copy link
Member

rust-lang/rust#55131 also seems very relevant.

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

No branches or pull requests

2 participants