Skip to content

Floating-point limits (float.h)

Include float.h for the floating-point range and precision macros.

Macros

Name Meaning
FLT_RADIX Exponent radix for floating-point values.
FLT_MANT_DIG Number of base-FLT_RADIX digits in the float significand.
FLT_DIG Decimal digits of precision for float.
FLT_EPSILON Difference between 1.0F and the next representable float.
FLT_MIN Smallest positive normalized float.
FLT_MAX Largest finite float.
FLT_MIN_EXP Minimum base-FLT_RADIX exponent for normalized float.
FLT_MAX_EXP Maximum base-FLT_RADIX exponent for normalized float.
FLT_MIN_10_EXP Minimum base-10 exponent for normalized float.
FLT_MAX_10_EXP Maximum base-10 exponent for normalized float.
DBL_MANT_DIG Alias of FLT_MANT_DIG because dcc has no double type.
DBL_DIG Alias of FLT_DIG because dcc has no double type.
DBL_EPSILON Alias of FLT_EPSILON because dcc has no double type.
DBL_MIN Alias of FLT_MIN because dcc has no double type.
DBL_MAX Alias of FLT_MAX because dcc has no double type.
DBL_MIN_EXP Alias of FLT_MIN_EXP because dcc has no double type.
DBL_MAX_EXP Alias of FLT_MAX_EXP because dcc has no double type.
DBL_MIN_10_EXP Alias of FLT_MIN_10_EXP because dcc has no double type.
DBL_MAX_10_EXP Alias of FLT_MAX_10_EXP because dcc has no double type.
LDBL_MANT_DIG Alias of DBL_MANT_DIG because dcc has no long double type.
LDBL_DIG Alias of DBL_DIG because dcc has no long double type.
LDBL_EPSILON Alias of DBL_EPSILON because dcc has no long double type.
LDBL_MIN Alias of DBL_MIN because dcc has no long double type.
LDBL_MAX Alias of DBL_MAX because dcc has no long double type.
LDBL_MIN_EXP Alias of DBL_MIN_EXP because dcc has no long double type.
LDBL_MAX_EXP Alias of DBL_MAX_EXP because dcc has no long double type.
LDBL_MIN_10_EXP Alias of DBL_MIN_10_EXP because dcc has no long double type.
LDBL_MAX_10_EXP Alias of DBL_MAX_10_EXP because dcc has no long double type.

Runtime model

The DCC C Compiler has only one floating type: 32-bit IEEE-style float. There is no distinct double or long double representation. The DBL_* and LDBL_* macros are therefore aliases of the FLT_* values so portable source can compile, but they intentionally describe the same single-precision target.

Precision

FLT_MANT_DIG is 24, so integers up to 2^24 are exactly representable and larger integers may round when converted to float. FLT_DIG is 6, reflecting the number of decimal digits that can be represented without change on a round trip through this target's float format.

Use FLT_EPSILON for small tolerance checks rather than expecting decimal results to compare exactly:

#include <float.h>

int nearly_same(float a, float b)
{
    float d = a - b;
    if (d < 0.0f)
        d = -d;
    return d <= FLT_EPSILON;
}

See Floating-point math for math-library accuracy and mixed-type gotchas.