rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.79k stars 261 forks source link

i32 -> u32 conversion described as "no-op" #261

Closed jgarvin closed 3 years ago

jgarvin commented 3 years ago

From here: https://doc.rust-lang.org/nomicon/casts.html

casting between two integers of the same size (e.g. i32 -> u32) is a no-op

A signed integer can contain values an unsigned integer cannot, so even if this is true at the instruction level it seems misleading. Should maybe mention if Rust assumes 2s-complement representation?