Draft 2002-02-21

<cfloat>

The <cfloat> header is the C++ wrapper for the C standard <float.h> header. It defines parameters that characterize floating point types. See <climits> for the C characterization of the integral types.

The native C++ header, <limits>, defines the same information (and more), but without cumbersome macros. When writing new C++ code, use <limits> instead of <cfloat>.

There are three sets of macros, each set describing a different fundamental type. For each type, the set of macros have a common prefix: float (FLT_), double (DBL_), and long double (LDBL_). Each set characterizes a floating point value as a sign, a significant, and an exponent:

x = sign × significand × base exponent

A normalized floating point value is zero, or the first digit of its significand is non-zero. (Some floating point implementations do not store the first bit of a significand because it is known to be 1 when the entire value is not zero.)

Only FLT_RADIX expands to a constant expression. All other macros in <cfloat> expand to numeric expressions, but the values might not be constant.

DBL_DIG macro

Syntax

int DBL_DIG

Description

Number of significant decimal digits for any number that can be stored in a double.

DBL_EPSILON macro

Syntax

double DBL_EPSILON 

Description

The difference between 1 and the smallest value greater than one that can be stored in a double.

DBL_MANT_DIG macro

Syntax

int DBL_MANT_DIG

Description

Number of FLT_RADIX digits in the significand of a double.

DBL_MAX macro

Syntax

double DBL_MAX 

Description

Maximum finite double value.

DBL_MAX_10_EXP macro

Syntax

int DBL_MAX_10_EXP 

Description

Maximum decimal exponent for a finite double.

DBL_MAX_EXP macro

Syntax

int DBL_MAX_EXP

Description

Maximum exponent of a FLT_RADIX base for a finite double.

DBL_MIN macro

Syntax

double DBL_MIN

Description

Minimum normalized, positive double value.

DBL_MIN_10_EXP macro

Syntax

int DBL_MIN_10_EXP

Description

Minimum negative decimal exponent for a normalized double.

DBL_MIN_EXP macro

Syntax

int DBL_MIN_EXP

Description

Minimum negative exponent of a FLT_RADIX base for a normalized double.

FLT_DIG macro

Syntax

int FLT_DIG

Description

Number of significant decimal digits for any number that can be stored in a float.

FLT_EPSILON macro

Syntax

float FLT_EPSILON

Description

The difference between 1 and the smallest value greater than one that can be stored in a float.

FLT_MANT_DIG macro

Syntax

int FLT_MANT_DIG

Description

Number of FLT_RADIX digits in the significand of a float.

FLT_MAX macro

Syntax

float FLT_MAX

Description

Maximum finite float value.

FLT_MAX_10_EXP macro

Syntax

int FLT_MAX_10_EXP

Description

Maximum decimal exponent for a finite float.

FLT_MAX_EXP macro

Syntax

int FLT_MAX_EXP

Description

Maximum exponent of a FLT_RADIX base for a finite float.

FLT_MIN macro

Syntax

float FLT_MIN

Description

Minimum normalized, positive float value.

FLT_MIN_10_EXP macro

Syntax

int FLT_MIN_10_EXP

Description

Minimum negative decimal exponent for a normalized float.

FLT_MIN_EXP macro

Syntax

int FLT_MIN_EXP

Description

Minimum negative exponent of a FLT_RADIX base for a normalized float.

FLT_RADIX macro

Syntax

int FLT_RADIX

Description

The FLT_RADIX macro is an integer that specifies the radix for the floating point implementation. For example, IEC 60559 (IEEE 754) has a FLT_RADIX of 2.

FLT_ROUNDS macro

Syntax

int FLT_ROUNDS

Description

The FLT_ROUNDS macro specifies how the implementation rounds floating point numbers. Table 13-2 lists the possible values. An implementation can define additional values with other meanings.

Table 13-2: Floating point rounding mode
Value Description
-1 indeterminable
0 rounds towards zero
1 rounds to nearest
2 rounds up (to positive infinity)
3 rounds down (to negative infinity)

LDBL_DIG macro

Syntax

int LDBL_DIG

Description

Number of significant decimal digits for any number that can be stored in a long double.

LDBL_EPSILON macro

Syntax

long double LDBL_EPSILON

Description

The difference between 1 and the smallest value greater than one that can be stored in a long double.

LDBL_MANT_DIG macro

Syntax

int LDBL_MANT_DIG

Description

Number of FLT_RADIX digits in the significand of a long double.

LDBL_MAX macro

Syntax

long double LDBL_MAX

Description

Maximum finite long double value.

LDBL_MAX_10_EXP macro

Syntax

int LDBL_MAX_10_EXP

Description

Maximum decimal exponent for a finite long double.

LDBL_MAX_EXP macro

Syntax

int LDBL_MAX_EXP

Description

Maximum exponent of a FLT_RADIX base for a finite double.

LDBL_MIN macro

Syntax

long double LDBL_MIN

Description

Minimum normalized, positive long double value.

LDBL_MIN_10_EXP macro

Syntax

int LDBL_MIN_10_EXP

Description

Minimum negative decimal exponent for a normalized long double.

LDBL_MIN_EXP macro

Syntax

int LDBL_MIN_EXP

Description

Minimum negative exponent of a FLT_RADIX base for a normalized long double.