Created
October 16, 2018 01:27
-
-
Save m1el/dc18a85b82357589825d9ffa4532b0a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut failed = 0usize; | |
for i in 0..=u32::max_value() { | |
if i & 0xffffff == 0 { println!("{}", i); } | |
let x = f32::from_bits(i); | |
let r_std = x.round(); | |
let r_hoc = (x+0.5).floor(); | |
if r_std.to_bits() != r_hoc.to_bits() { | |
println!("round for {} fails", x); | |
failed += 1; | |
if failed > 10 { break } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment