Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values

Finding the Next Representable Value in a Specific Direction (nextafter)
Finding the Next Greater Representable Value (float_next)
Finding the Next Smaller Representable Value (float_prior)
Calculating the Representation Distance Between Two Floating Point Values (ULP) float_distance
Advancing a Floating Point Value by a Specific Representation Distance (ULP) float_advance

Unit of Least Precision or Unit in the Last Place is the gap between two different, but as close as possible, floating-point numbers.

Most decimal values, for example 0.1, cannot be exactly represented as floating-point values, but will be stored as the closest representable floating-point.

Functions are provided for finding adjacent greater and lesser floating-point values, and estimating the number of gaps between any two floating-point values.

The floating-point type FPT must have has a fixed number of bits in the representation. The number of bits may set at runtime, but must be the same for all numbers. For example, NTL::quad_float type (fixed 128-bit representation) or NTL::RR type (arbitrary but fixed decimal digits, default 150) but not a type that extends the representation to provide an exact representation for any number, for example XRC eXact Real in C.