Skip to main content

float.h

float.h defines a number of macros for the floating point types float, double, and long double, specifying the range and precision of these types.

(1) FLT_ROUNDS

The macro FLT_ROUNDS indicates the direction of rounding for the current floating point addition.

It has the following possible values.

-1: indeterminate.

  • 0: rounds towards zero.
  • 1: rounds to the nearest integer.
  • 2: Rounds to positive infinity.
  • 3: Rounds to negative infinity.

(2) FLT_RADIX

The macro FLT_RADIX indicates the base of the exponential part of scientific notation (base), usually always 2.

(3) The maximum value of a floating point type

  • FLT_MAX
  • DBL_MAX
  • LDBL_MAX

(4) The smallest positive value of a floating point type

  • FLT_MIN
  • DBL_MIN
  • LDBL_MIN

(5) The smallest difference between two floating-point numbers of the same type that can be expressed (minimum precision)

  • FLT_EPSILON
  • DBL_EPSILON
  • LDBL_EPSILON

(6) DECIMAL_DIG

The macro DECIMAL_DIG indicates the number of decimal valid bits.

(7) FLT_EVAL_METHOD

The macro FLT_EVAL_METHOD indicates the type conversion for floating point operations.

It may have the following values.

-1: not determined.

  • 0: arithmetic in the current type.
  • 1: operations of type float and double use the range and precision of type double to evaluate.
  • 2: All floating point operations use the range and precision of the long double type.

(8) The number of trailing parts of a floating point number

  • FLT_MANT_DIG
  • DBL_MANT_DIG
  • LDBL_MANT_DIG

(9) The number of significant digits in the exponent part of a floating-point number (in decimal)

  • FLT_DIG
  • DBL_DIG
  • LDBL_DIG

(10) The smallest power of the exponential part of scientific notation (negative numbers)

  • FLT_MIN_EXP
  • DBL_MIN_EXP
  • LDBL_MIN_EXP

(11) The lowest power of the exponential part of scientific notation in decimal (negative numbers)

  • FLT_MIN_10_EXP
  • DBL_MIN_10_EXP
  • LDBL_MIN_10_EXP

(12) Maximum power of the exponential part of scientific notation

  • FLT_MAX_EXP
  • DBL_MAX_EXP
  • LDBL_MAX_EXP

(13) The exponential part of scientific notation to the greatest power of ten

  • FLT_MAX_10_EXP
  • DBL_MAX_10_EXP
  • LDBL_MAX_10_EXP