<cfloat> float.h in C/C++ with Examples

Last Updated : 12 Aug, 2026

The <float.h> header file in C defines platform-dependent and implementation-specific characteristics of floating-point types. These macros provide information about the precision, range, rounding behavior, and representation of float, double, and long double.

Floating-Point Representation

A floating-point number consists of four main parts:

  • Sign: Indicates whether the number is positive or negative.
  • Base (Radix): Represents the base used for the exponent representation, such as 2 for binary, 10 for decimal, and 16 for hexadecimal.
  • Mantissa (Significand): Represents a sequence of digits in the given base. The number of significant digits determines the precision.
  • Exponent: Determines the scale of the floating-point number and has a minimum and maximum range.
Value of floating point = Âą precision X baseexponent

Floating-Point Macro Constants

Macro constants Library macros are hardware-specific values for the floating-point types.FLT implies type float, DBL implies double, and LDBL implies long double, DIG implies digits, MANT implies mantissa, EXP implies exponent.

1. FLT_RADIX: Base for all floating-point types

Minimum value is 2

2. FLT_DIG: Number of decimal digits that can be rounded into a floating-point type and back again to the same decimal digits, without loss in precision.

Minimum value is 6

3. DBL_DIG or LDBL_DIG: Number of decimal digits that can be rounded into a floating-point and back without change in the number of decimal digits.

Minimum value is 10

4. DECIMAL_DIG: Decimal digits needed to represent floating-point value

No Minimum value

5. FLT_MANT_DIG or DBL_MANT_DIG or LDBL_MANT_DIG: Precision of mantissa i.e. the number of digits that conform the significand.

No Minimum value

6. FLT_MIN_EXP or DBL_MIN_EXP or LDBL_MIN_EXP: Minimum negative integer value for the exponent that generates a normalized floating-point number.

No Minimum value

7. FLT_MIN_10_EXP or DBL_MIN_10_EXP or LDBL_MIN_10_EXP: Minimum negative integer value for the exponent of a base-10 expression that would generate a normalized floating-point number.

Maximum value is -37

8. FLT_MAX_EXP or DBL_MAX_EXP or LDBL_MAX_EXP: Maximum integer value for the exponent that generates a normalized floating-point number. \

No Minimum value

9. FLT_MAX_10_EXP or DBL_MAX_10_EXP or LDBL_MAX_10_EXP: Maximum integer value for the exponent of a base-10 expression that would generate a normalized floating-point number.

Minimum value is 37

10. FLT_MAX or DBL_MAX or LDBL_MAX: Maximum finite representable floating-point number.

Minimum value is 1037

11. FLT_EPSILON: Difference between 1 and the least value greater than 1 that is representable.

Maximum value is 10-5

12. DBL_EPSILON or LDBL_EPSILON: Difference between 1 and the least value greater than 1 that is representable.

Maximum value is 10-9

13. FLT_MIN or DBL_MIN or LDBL_MIN: Minimum representable positive floating-point number.

Maximum value is 10-37

14. FLT_ROUNDS: Rounds off the floating-point number Different possible values are:

  • -1 : indeterminate
  • 0 : towards zero
  • 1 : towards one
  • 2 : towards positive infinity
  • 3 : towards negative infinity

15. FLT_EVAL_METHOD: Rounds off the floating-point number Different possible values are:

  • -1 : undetermined
  • 0 : evaluate just to the range
  • and precision of the type
  • 1 : evaluate float and double as double,
  • and long double as long double.
  • 2 : evaluate all as long double and Other
  • negative values indicate an
  • implementation defined behavior.

Below is the program to demonstrate the working of macros constants in cfloat library.

CPP
// C++ program to demonstrate working
// of macros constants in cfloat library

#include <cfloat>
#include <iostream>
using namespace std;

int main()
{
    cout << "FLT_RADIX : "
         << FLT_RADIX << endl;
    cout << "FLT_DIG : "
         << FLT_DIG << endl;
    cout << "DECIMAL_DIG : "
         << DECIMAL_DIG << endl;
    cout << "FLT_MIN_10_EXP : "
         << FLT_MIN_10_EXP << endl;
    cout << "FLT_MAX_EXP : "
         << FLT_MAX_EXP << endl;
    cout << "FLT_MAX_10_EXP : "
         << FLT_MAX_10_EXP << endl;
    cout << "FLT_MAX : "
         << FLT_MAX << endl;
    cout << "FLT_MIN : "
         << FLT_MIN << endl;
    return 0;
}

Output
FLT_RADIX : 2
FLT_DIG : 6
DECIMAL_DIG : 21
FLT_MIN_10_EXP : -37
FLT_MAX_EXP : 128
FLT_MAX_10_EXP : 38
FLT_MAX : 3.40282e+38
FLT_MIN : 1.17549e-38
Comment