<cfloat>

The <cfloat> header is the C++ version of the C standard <float.h> header. It defines parameters that characterize floating-point types in the same way <climits> does for the integral types. The native C++ header, <limits>, defines the same information (and more) using templates instead of macros.

There are three sets of macros, each describing a different fundamental type. For each type, the corresponding set of macros has a common prefix: float (FLT_), double (DBL_), and long double (LDBL_). Each set characterizes a floating-point value as a sign, a significand (sometimes called the mantissa), a base, and an exponent:

x = sign × significand × base exponent

In everyday arithmetic, we are used to working with a base of 10. (The base is also called the radix.) The most common bases for computer arithmetic, however, are 16 and 2. Many modern workstations use the IEC 60559 (IEEE 754) standard for floating-point arithmetic, which uses a base of 2.

The significand is a string of digits in the given base. There is an implied radix point at the start of the significand so the value of the significand is always less than 1. (A radix point is the generalization of a decimal point for any radix.)

A floating-point value is normalized if the first digit of its significand is nonzero, or if the entire value is 0. A value that is not normalized is denormalized.

The precision of a floating-point type is the maximum number of places in the significand. The range of a floating-point type depends ...

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.