summaryrefslogtreecommitdiff
path: root/Integers can overflow if compiled with --release.md
diff options
context:
space:
mode:
authorJasper Ras <jras@hostnet.nl>2025-08-03 22:29:47 +0200
committerJasper Ras <jras@hostnet.nl>2025-08-03 22:29:47 +0200
commit931eb0894e7cd3717f1218f0eb06382b11734c13 (patch)
treeb6ad9b0d98a8f26e496c91ad3f24d1c855b654df /Integers can overflow if compiled with --release.md
parentaf98004d2cf437603f47f4224110a80d76d0d7de (diff)
vault backup: 2025-08-03 22:29:47
Diffstat (limited to 'Integers can overflow if compiled with --release.md')
-rw-r--r--Integers can overflow if compiled with --release.md11
1 files changed, 11 insertions, 0 deletions
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]]