Skip to content

Commit 4226cec

Browse files
committed
Update example for changes in float behavior
1 parent e5d0d53 commit 4226cec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/expressions/operator-expr.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ reference types and `mut` or `const` in pointer types.
444444
assert_eq!(42.9f32 as i32, 42);
445445
assert_eq!(-42.9f32 as i32, -42);
446446
assert_eq!(42_000_000f32 as i32, 42_000_000);
447-
println!("Undefined Behavior: {}", 1_000_000_000_000_000f32 as i32);
448-
println!("Undefined Behavior: {}", std::f32::NEG_INFINITY as i32);
449-
println!("Undefined Behavior: {}", std::f32::NAN as i32);
447+
assert_eq!(std::f32::NAN as i32, 0);
448+
assert_eq!(1_000_000_000_000_000f32 as i32, 0x7fffffffi32);
449+
assert_eq!(std::f32::NEG_INFINITY as i32, -0x80000000i32);
450450
```
451451

452452
* Casting from an integer to float will produce the closest possible float \*

0 commit comments

Comments
 (0)