liveBook · Manning

Numerical overflow

Also called numeric overflow, arithmetic overflow

Numerical overflow occurs when an arithmetic result falls outside the range representable by its numeric type or format.

How 8 Manning books explain it

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
Uses representability to explain arithmetic results and identifies integer overflow as a safety concern.
How deep it goes
Defines overflow and explains representable size_t results, while deferring the details of how C handles overflow.
Examples
Uses a product greater than SIZE_MAX to illustrate an unrepresentable size_t result.
What you can do after
Evaluate whether a mathematical product fits within the size_t range and recognize overflow as a safety concern.

Read how Modern C explains numerical overflow →

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 integer overflow to connect Rust safety with fixed-width data representation.
How deep it goes
Explains ranges and bit patterns through overflow examples, contrasting panic and wrapping under different compilation settings.
Examples
Uses a u16 increment loop and a u8 addition of 200 plus 200 to demonstrate out-of-range arithmetic.
What you can do after
Evaluate integer calculations for range limits and understand why they may panic or wrap under different build settings.

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.

Read how Hacking Cryptography explains numerical overflow →

GPU Programming with Triton

A numerical condition in which a computed value exceeds the range representable by its number format.

How it is used
Motivates stable softmax computation by showing how exponentials exceed floating-point ranges.
How deep it goes
Quantifies float32 and float16 overflow thresholds and derives max-shifted softmax, while deferring its kernel implementation.
Examples
Uses exp(88.7) in float32, exp(12) in float16, and logits or attention scores as examples.
What you can do after
Apply max-shifted softmax to prevent exponential overflow while preserving the normalized result.

Read how GPU Programming with Triton explains numerical overflow →

Fast Python: High performance techniques for large datasets

How it is used
Uses image-brightening arithmetic to show how a narrow pixel type can produce incorrect results.
How deep it goes
Demonstrates overflow with concrete values, diagnoses a plausible-looking result, and shows widening and clamping as mitigation.
Examples
Brightens grayscale pixels by adding 5 or doubling, then checks the maximum and clamps widened results.
What you can do after
Apply NumPy widening, clamping, and conversion to prevent overflow from corrupting image-brightness results.

Read how Fast Python: High performance techniques for large datasets explains numerical overflow →

Also covered in

What to know first

Related concepts

Questions about numerical overflow

What is numerical overflow?

Numerical overflow occurs when an arithmetic result falls outside the range representable by its numeric type or format.

Which Manning books explain numerical overflow?

100 Java Mistakes and How to Avoid Them, Modern C, Clojure: The Essential Reference, Rust in Action: Systems programming concepts and techniques, 100 Go Mistakes and How to Avoid Them, Hacking Cryptography, GPU Programming with Triton and Fast Python: High performance techniques for large datasets.

What should I know before learning numerical overflow?

Manning books that teach numerical overflow usually introduce integer, unsigned integer, floating-point arithmetic and uint8 first.

What is numerical overflow also called?

Numerical overflow is also called numeric overflow or arithmetic overflow.

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.