Skip to content

Commit 7d19c44

Browse files
bors[bot]Nemo157
andauthored
Merge #28
28: Avoid change in float rounding behaviour in tests r=Nemo157 a=Nemo157 rust-lang/rust#102935 changed the behaviour of `format!("{:.0}", 0.5)` to round to 0 instead of 1 for consistency. The test case I copied from `std` was using this, so change to using 1.5 which has the same behaviour on stable and nightly. Co-authored-by: Wim Looman <[email protected]>
2 parents 0091f96 + cef5a0f commit 7d19c44

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/std/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn test_format_f64() {
99
assert_eq!("10", format!("{:.0}", 9.9f64));
1010
assert_eq!("9.8", format!("{:.1}", 9.849f64));
1111
assert_eq!("9.9", format!("{:.1}", 9.851f64));
12-
assert_eq!("1", format!("{:.0}", 0.5f64));
12+
assert_eq!("2", format!("{:.0}", 1.5f64));
1313
assert_eq!("1.23456789e6", format!("{:e}", 1234567.89f64));
1414
assert_eq!("1.23456789e3", format!("{:e}", 1234.56789f64));
1515
assert_eq!("1.23456789E6", format!("{:E}", 1234567.89f64));
@@ -25,7 +25,7 @@ fn test_format_f32() {
2525
assert_eq!("10", format!("{:.0}", 9.9f32));
2626
assert_eq!("9.8", format!("{:.1}", 9.849f32));
2727
assert_eq!("9.9", format!("{:.1}", 9.851f32));
28-
assert_eq!("1", format!("{:.0}", 0.5f32));
28+
assert_eq!("2", format!("{:.0}", 1.5f32));
2929
assert_eq!("1.2345679e6", format!("{:e}", 1234567.89f32));
3030
assert_eq!("1.2345679e3", format!("{:e}", 1234.56789f32));
3131
assert_eq!("1.2345679E6", format!("{:E}", 1234567.89f32));

0 commit comments

Comments
 (0)