blob: 94d80cacd2001c73ef726a74719fe1d0ef951aab (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
[[Rust]]
Integers that overflow wrap around. ie in an i8 256 -> 0, 257 -> 1, etc.
The standard library includes families of methods for primitive numeric types to handle wrapping:
- `wrapping_*`: wrap in all modes
- `checked_*`: return None if overflow
- `overflowing_*`: return val + bool that indicates whether overflow occurred
- `saturating_*`: saturate at the minimum or maximum values
[[Saturating a value when wrapping]]
|