rustc 1.82.0 (f6e511eec 2024-10-15)
println!("{}", 100 as u32 + (0 as u32) << 8);
Result:25600
rustc 1.82.0 (f6e511eec 2024-10-15)
println!("{}", 100 as u32 + (0 as u32) << 8);
Result:25600
Also, clippy can help avoid surprises
warning: operator precedence can trip the unwary
--> src/main.rs:2:20
|
2 | println!("{}", 100 as u32 + (0 as u32) << 8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider parenthesizing your expression: `(100 as u32 + (0 as u32)) << 8`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
= note: `#[warn(clippy::precedence)]` on by default
You are right, thanks