Provides checked!
, panicking!
, wrapping!
and saturating!
macros to change how arithmetic overflows are handled.
This crate currently not published on crates.io
use arithmetic_mode::wrapping;
wrapping! { 1_i32 + 2_i32 - 3_i32 };
- Add
+
- Sub
-
- Mul
*
- Div
/
- Shl
<<
(exceptsaturating
, due to rust-lang/libs-team#230) - Shr
>>
(exceptsaturating
, due to rust-lang/libs-team#230)
- For most operations, constraining the numeric literals are required (e.g.
2_i32
instead of2
), due to rust-lang/rust#24124.