4 ms·
Rust has all these arithmetic modes on its integer primitives. The operators, such as +, panic on overflow in debug buids and wrap as two's complement in relea
by hsivonen 9y ago
Rust has all these arithmetic modes on its integer primitives.
The operators, such as +, panic on overflow in debug buids and wrap as two's complement in release builds.
As methods you get:
1) Two's complement wrapping (even in debug builds)
2) Saturation
3) Overflow checking (these return Option<T>
- masklinn 9y ago> 1) Two's complement wrapping (even in debug builds) As it's a relatively common need, there's also a wrapper struct for this one: https://doc.rust-lang.org/core/num/struct.Wrapping.html https://doc.rust-lang.org/core/num/struct.Wrapping.html