float.h
- Macros for Floating Point Types
This page was translated by a robot.
The floating point types built into the C and C++ languages float, doubleand long doubleare defined differently depending on the system and compiler and can therefore cover different number ranges. The possible values in the currently used compiler are defined as constants, which floatcan be queried using the library.
C C++
#include <float.h> #include <cfloat>
There are macros for each of the three floating point types that describe the minimum and maximum value that can be displayed. However, unlike integers, the minimum is not a negative value, but the smallest value that is greater than 0(zero). Floating-point numbers always have a sign bit, which means that the values described by the macros can also be used for negative values.
1.175494e-38 3.402823e+38 2.225074e-308 1.797693e+308 3.362103e-4932 1.189731e+4932
#include <stdio.h> #include <float.h> int main(){ printf("%e\n", FLT_MIN); printf("%e\n", FLT_MAX); printf("%le\n", DBL_MIN); printf("%le\n", DBL_MAX); printf("%Le\n", LDBL_MIN); printf("%Le\n", LDBL_MAX); return 0; }
It should be noted that depending on the system, the output values may differ. The values given on this page are those that were output on the author's system.
The floatlibrary contains additional macros with constants for the base (radix), mantissa, exponent, machine epsilon and number of significant digits of all three floating-point types. Due to the complex topic of floating-point arithmetic, these macros are only listed in the following table with the values defined by the author. For further information, reference is made to the floating point coding and other sources. It should be noted that the number of mantissa bits specified here always includes an implicit bit.
FLT_RADIX 2 The basis of the exponential representation FLT_ROUNDS 1 rounding method FLT_EVAL_METHOD 0 Floating point evaluation method DECIMAL_DIG 21 Maximum number of rounding-precise decimal places FLT_MANT_DIG 24 Number of radix digits of the mantissa for float DBL_MANT_DIG 53 Number of radix digits of the mantissa for double LDBL_MANT_DIG 64 Number of radix digits of the mantissa for long double FLT_DIG 6 Number of exact decimal places for float DBL_DIG 15 Number of exact decimal places for double LDBL_DIG 18 Number of exact decimal places for long double FLT_MIN_EXP -125 Minimum radix exponent for normalized float DBL_MIN_EXP -1021 Minimum radix exponent for normalized double LDBL_MIN_EXP -16381 Minimum radix exponent for normalized long double FLT_MIN_10_EXP -37 Minimum decimal exponent for normalized float DBL_MIN_10_EXP -307 Minimum decimal exponent for normalized double LDBL_MIN_10_EXP -4931 Minimum decimal exponent for normalized long double FLT_MAX_EXP 128 Maximum radix exponent for normalized float DBL_MAX_EXP 1024 Maximum radix exponent for normalized double LDBL_MAX_EXP 16384 Maximum radix exponent for normalized long double FLT_MAX_10_EXP 38 Maximum decimal exponent for normalized float DBL_MAX_10_EXP 308 Maximum decimal exponent for normalized double LDBL_MAX_10_EXP 4932 Maximum decimal exponent for normalized long double FLT_EPSILON 1.192093e-07 Machine Epsilon for float DBL_EPSILON 2.220446e-16 Machine Epsilon for double LDBL_EPSILON 1.084202e-19 Machine Epsilon for long double