liveBook · Manning

Integer wraparound

Integer wraparound is arithmetic behavior in which an out-of-range fixed-width integer result cycles or is reduced modulo the type’s representable range.

How 3 Manning books explain it

Code Like a Pro in Rust

How it is used
Makes fixed-width overflow behavior explicit in Rust arithmetic and tests.
How deep it goes
Demonstrates boundary assertions and a property-test repair, but defers deeper treatment of traits.
Examples
Uses unsigned boundary assertions and an `i64` property test that first fails on overflow, then passes with wrapping addition.
What you can do after
Apply it via Rust’s `wrapping_*` methods or `num_traits::WrappingAdd`, and test overflow behavior explicitly.

Read how Code Like a Pro in Rust explains integer wraparound →

Modern C

Unsigned wraparound is the reduction of an out-of-range unsigned arithmetic result into the representable range by modular reduction.

How it is used
Explains modular behavior in unsigned arithmetic, size_t calculations, clock-style remainders, and loop-index safety.
How deep it goes
Defines reduction modulo SIZE_MAX + 1 and works through boundary examples, but does not develop implementation internals.
Examples
Uses clock arithmetic, minute remainders, SIZE_MAX + 1, 0 - 1, and explicit loop-index checks.
What you can do after
Apply it via C unsigned types while recognizing boundary values and guarding loop increments against unintended wraparound.

Read how Modern C explains integer wraparound →

Go in Action, Second Edition

Integer wraparound is the behavior in which arithmetic outside an integer type's representable range produces a value obtained by cycling through its fixed-width bit representation.

How it is used
Explains integer-type choices and safer function parameter design when values may cross signed or unsigned boundaries.
How deep it goes
Demonstrates bit-level boundary behavior and conversion consequences, then stops at validation guidance rather than broader arithmetic internals.
Examples
Uses uint64 subtraction, an unsigned-only function, negative literals, converted negative values, and explicit error checking.
What you can do after
Diagnose unexpected large unsigned values and design signed, validated function inputs that expose negative-value errors.

Read how Go in Action, Second Edition explains integer wraparound →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.