- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-floating-pointArea: Floating point numbers and arithmeticArea: Floating point numbers and arithmeticC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.
Description
I tried this code:
#![feature(float_next_up_down)]
fn main() {
    println!("{:?}", -0.0f32.next_up()); // -1e-45
    println!("{:?}", 0.0f32.next_up());  //  1e-45
    println!("{:?}", -0.0f64.next_up()); // -5e-324
    println!("{:?}", 0.0f64.next_up());  //  5e-324
}I expected to see this happen:
- Accoding to 3173-float-next-up-down - The Rust RFC Book:
- -0.0f32.next_up()should return the smallest non-zero positive- f32value (- f32::from_bits(0x1),- 1e-45).
- -0.0f64.next_up()should return the smallest non-zero positive- f64value (- f64::from_bits(0x1),- 5e-324).
 
Instead, this happened:
- -0.0f32.next_up()returns- -1e-45.
- -0.0f64.next_up()returns- -5e-324.
Meta
rustc --version --verbose:
rustc 1.85.0-nightly (21fe748be 2024-12-11)
binary: rustc
commit-hash: 21fe748be15271ea5804e0507cd699b675efe038
commit-date: 2024-12-11
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5
Metadata
Metadata
Assignees
Labels
A-floating-pointArea: Floating point numbers and arithmeticArea: Floating point numbers and arithmeticC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.