Merge pull request #277 from JohnTitor/note-fixed-int-2s-complement

Clarify casting between the same size fixed ints
pull/280/head
Eric Huss 3 years ago committed by GitHub
commit 19f63118e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,6 +46,7 @@ expression, `e as U2` is not necessarily so.
For numeric casts, there are quite a few cases to consider: For numeric casts, there are quite a few cases to consider:
* casting between two integers of the same size (e.g. i32 -> u32) is a no-op * casting between two integers of the same size (e.g. i32 -> u32) is a no-op
(Rust uses 2's complement for negative values of fixed integers)
* casting from a larger integer to a smaller integer (e.g. u32 -> u8) will * casting from a larger integer to a smaller integer (e.g. u32 -> u8) will
truncate truncate
* casting from a smaller integer to a larger integer (e.g. u8 -> u32) will * casting from a smaller integer to a larger integer (e.g. u8 -> u32) will

Loading…
Cancel
Save