Skip to content

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

Closed

Description

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.

Activity

  1. antoyo commented on Feb 1, 2022

    @antoyo
    Contributor

    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

  2. RalfJung commented on Feb 20, 2022

    @RalfJung
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions