From 931eb0894e7cd3717f1218f0eb06382b11734c13 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Sun, 3 Aug 2025 22:29:47 +0200 Subject: vault backup: 2025-08-03 22:29:47 --- Integers can overflow if compiled with --release.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Integers can overflow if compiled with --release.md (limited to 'Integers can overflow if compiled with --release.md') diff --git a/Integers can overflow if compiled with --release.md b/Integers can overflow if compiled with --release.md new file mode 100644 index 0000000..94d80ca --- /dev/null +++ b/Integers can overflow if compiled with --release.md @@ -0,0 +1,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]] -- cgit v1.2.3