@@ -22,7 +22,7 @@ fn main() {
22
22
let integer = decimal as u8;
23
23
let character = integer as char;
24
24
25
- // Error! There are limitations in conversion rules.
25
+ // Error! There are limitations in conversion rules.
26
26
// A float cannot be directly converted to a char.
27
27
let character = decimal as char;
28
28
// FIXME ^ Comment out this line
@@ -52,7 +52,7 @@ fn main() {
52
52
53
53
// Unless it already fits, of course.
54
54
println!(" 128 as a i16 is: {}", 128 as i16);
55
-
55
+
56
56
// 128 as u8 -> 128, whose value in 8-bit two's complement representation is:
57
57
println!(" 128 as a i8 is : {}", 128 as i8);
58
58
@@ -61,21 +61,21 @@ fn main() {
61
61
println!("1000 as a u8 is : {}", 1000 as u8);
62
62
// and the value of 232 in 8-bit two's complement representation is -24
63
63
println!(" 232 as a i8 is : {}", 232 as i8);
64
-
65
- // Since Rust 1.45, the `as` keyword performs a *saturating cast*
66
- // when casting from float to int. If the floating point value exceeds
67
- // the upper bound or is less than the lower bound, the returned value
64
+
65
+ // Since Rust 1.45, the `as` keyword performs a *saturating cast*
66
+ // when casting from float to int. If the floating point value exceeds
67
+ // the upper bound or is less than the lower bound, the returned value
68
68
// will be equal to the bound crossed.
69
-
69
+
70
70
// 300.0 as u8 is 255
71
71
println!(" 300.0 as u8 is : {}", 300.0_f32 as u8);
72
72
// -100.0 as u8 is 0
73
73
println!("-100.0 as u8 is : {}", -100.0_f32 as u8);
74
74
// nan as u8 is 0
75
75
println!(" nan as u8 is : {}", f32::NAN as u8);
76
-
77
- // This behavior incurs a small runtime cost and can be avoided
78
- // with unsafe methods, however the results might overflow and
76
+
77
+ // This behavior incurs a small runtime cost and can be avoided
78
+ // with unsafe methods, however the results might overflow and
79
79
// return **unsound values**. Use these methods wisely:
80
80
unsafe {
81
81
// 300.0 as u8 is 44
0 commit comments