Numerical overflow
Numerical overflow is the condition in which an arithmetic result falls outside the range representable by its numeric type or format.
100 Java Mistakes and How to Avoid Them
Floating-point overflow is a computation exceeding the finite representable range of a floating-point type, typically producing infinity.
- How it is used
- Guards Java numerical calculations, comparisons, loops, and scaled quantities against silent incorrect results.
- How deep it goes
- Explains Java integral wraparound with worked arithmetic, then applies it to APIs, comparisons, loops, files, and money without two’s-complement internals.
- Examples
- Uses a near-limit arithmetic expression, short-based protein alignment, Excel row APIs, subtraction comparators, inclusive loops, and large-file offsets.
- What you can do after
- Diagnose/debug with it by recognizing wraparound-prone expressions and selecting safer types, comparisons, bounds, or checked arithmetic.
Read how 100 Java Mistakes and How to Avoid Them explains numerical overflow →
Modern C
Arithmetic overflow is the condition in which an arithmetic result is outside the range representable by its type.
- How it is used
- Marks the boundary between exact integer computation and results outside a type’s range, while serving as a C safety concern.
- How deep it goes
- Defines overflow using `size_t` and `SIZE_MAX`, then distinguishes signed types without detailing how C handles overflowing results.
- Examples
- Uses `size_t` arithmetic, a product exceeding `SIZE_MAX`, and paired signed and unsigned loops.
- What you can do after
- Evaluate/understand when integer arithmetic yields an exact result and why type range must be considered before relying on one.
Clojure: The Essential Reference
Integer overflow is the condition in which an integer computation exceeds the representable range and wraps or otherwise produces a bounded-width result.
- How it is used
- Distinguishes overflow detection, arbitrary-precision promotion, and intentional wraparound when choosing Clojure arithmetic operators.
- How deep it goes
- Explains long and int boundary rollover, unchecked-operator arities, and checked exceptions, with bit layouts rather than deeper runtime internals.
- Examples
- Uses boundary increments, repeated squaring, and a string hash built with unchecked multiplication and addition.
- What you can do after
- Apply it via Clojure arithmetic operators to select an exception, a promoted integer, or intentional wraparound.
Read how Clojure: The Essential Reference explains numerical overflow →
Rust in Action: Systems programming concepts and techniques
Integer overflow occurs when an integer computation exceeds the finite range representable by its fixed-width representation.
- How it is used
- Uses overflow to show how fixed-width integer representations affect program behavior.
- How deep it goes
- Explains bit-pattern limits and compares default and optimized execution, but does not develop an overflow-handling API.
- Examples
- Demonstrates a repeatedly incremented `u16` and an out-of-range `200 + 200` calculation stored in a `u8`.
- What you can do after
- Diagnose/debug with it when integer arithmetic panics or gives an unexpected result in an optimized build.
Read how Rust in Action: Systems programming concepts and techniques explains numerical overflow →
100 Go Mistakes and How to Avoid Them
Integer overflow is the condition in which an integer operation produces a result outside the representable range of the integer type.
- How it is used
- Protects Go counters and arithmetic from silent run-time wraparound and related bugs.
- How deep it goes
- Defines signed representation and supplies checks for increment, addition, and multiplication, but does not cover every arithmetic operation.
- Examples
- Uses an int32 counter, boundary-guard functions, addition guards, and multiplication validation.
- What you can do after
- Diagnose overflow risks and implement guards for increment, addition, and multiplication.
Read how 100 Go Mistakes and How to Avoid Them explains numerical overflow →
Hacking Cryptography
Integer overflow is the condition in which an arithmetic result exceeds the range representable by an integer type.
- How it is used
- Warns cryptographic implementers about fixed-width arithmetic failures that can corrupt allocations and other security-critical operations.
- How deep it goes
- Explains wrapping, two’s-complement boundaries, and an allocation vulnerability, then stops short of broader overflow-analysis techniques.
- Examples
- Uses signed-byte wraparound, a ring visualization, and OpenSSH’s nresp allocation and response-processing code.
- What you can do after
- Diagnose overflow-prone arithmetic in low-level security code and prioritize coverage, fuzzing, and undefined-behavior avoidance.
Fast Python: High performance techniques for large datasets
- How it is used
- Demonstrates overflow as a correctness problem while brightening grayscale image arrays.
- How deep it goes
- Works through 8-bit wraparound, including misleading doubled-image output, then widens, clips, and converts back.
- Examples
- Uses grayscale image arrays brightened by adding 5 or doubling pixel values.
- What you can do after
- Diagnose/debug with it by checking maxima and dtypes, widening the array, clipping values to 255, then converting back.
Read how Fast Python: High performance techniques for large datasets explains numerical overflow →
Related concepts
- undefined behaviorproduces · Undefined behavior is program execution for which the applicable language specification imposes no requirements on the resulting behavior or effects.
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.






