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

/ is not the same as f64::div for NaN #72411

Closed
jyn514 opened this issue May 21, 2020 · 1 comment
Closed

/ is not the same as f64::div for NaN #72411

jyn514 opened this issue May 21, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@jyn514
Copy link
Member

jyn514 commented May 21, 2020

I tried this code (playground):

use std::ops::Div;

fn main() {
    let slash: f64 = 0.0_f64 / 0.0_f64;
    let div: f64 = f64::div(0.0_f64, 0.0_f64);
    assert_eq!(slash.to_bits(), div.to_bits());
}

I expected to see this happen: The assert succeeds.

Instead, this happened: The assert fails.

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `9221120237041090560`,
 right: `18444492273895866368`', src/main.rs:6:5

Note that this only happens in debug mode, the second you turn on -C opt-level=1 the assertion passes.

Meta

1.45.0-nightly (2020-05-19 3a7dfda)
The bug is also present on 1.43 stable.

@jyn514
Copy link
Member Author

jyn514 commented May 21, 2020

Closing as duplicate of #55131 (but I hope that issue gets some love!)

@jyn514 jyn514 closed this as completed May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant