<cfloat> float.h in C/C++ with Examples Last Updated : 25 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report This header file consists of platform-dependent and implementation specific floating point values. A floating point has four parts. Sign Its value can be either negative or non-negative. Base It is also known as radix of exponent representation which represents different numbers with single number i.e. 2 for binary, 10 for decimal, 16 for hexadecimal, ... Mantissa It is also known as significand.It is a series of digits of the base. The number of digits in the series is known as precision. Exponent It is also known as characteristic is an integer between minimum emin and maximum emax. Value of floating point = ± precision X baseexponent 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. FLT_RADIX: Base for all floating-point types Minimum value is 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 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 DECIMAL_DIG: Decimal digits needed to represent floating-point value No Minimum value 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 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 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 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 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 FLT_MAX or DBL_MAX or LDBL_MAX: Maximum finite representable floating-point number. Minimum value is 1037 FLT_EPSILON: Difference between 1 and the least value greater than 1 that is representable. Maximum value is 10-5 DBL_EPSILON or LDBL_EPSILON: Difference between 1 and the least value greater than 1 that is representable. Maximum value is 10-9 FLT_MIN or DBL_MIN or LDBL_MIN: Minimum representable positive floating-point number. Maximum value is 10-37 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 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 (Machine Dependent): 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 Reference: http://www.cplusplus.com/reference/cfloat/ Comment More infoAdvertise with us Next Article Use of "stdafx.h" header in C++ with examples R ranadeepika2409 Follow Improve Article Tags : C++ CPP-Library C-Library Practice Tags : CPP Similar Reads fcvt() in C/C++ with Examples This function fcvt() converts the floating-point value to NULL-terminated ASCII string and returns a pointer to it. It is defined in the library function defined in stdlib.h header file. Syntax: char * fcvt (double value, int num, int * dec, int * sign); Parameters: 1. double value: It is the floati 2 min read log2() function in C++ with Examples The function log2() of cmath header file in C++ is used to find the logarithmic value with base 2 of the passed argument. Syntax: log2(x) Parameters: This function takes a value x, in the range [0, ∞] whose log value is to be found. Return Type: It returns the logarithmic value, as double, flo 2 min read Use of "stdafx.h" header in C++ with examples A header file contains the set of predefined standard library functions. The header file can be included in the program with the C preprocessing directive "#include". All the header files have ".h" extension. Syntax: #include <header_file> / "header_file" Here, #: A preprocessor directiveheade 2 min read Write a C program that won't compile in C++ Although C++ is designed to have backward compatibility with C, there can be many C programs that would produce compiler errors when compiled with a C++ compiler. Following is the list of the C programs that wonât compile in C++: Calling a function before the declarationUsing normal pointer with con 4 min read iomanip setiosflags() function in C++ with Examples The setiosflags() method of iomanip library in C++ is used to set the ios library format flags specified as the parameter to this method.Syntax: setiosflags (ios_base::format_flag) Parameters: This method accepts format_flag as a parameter which is the ios library format flag to be set by this metho 1 min read iomanip setprecision() function in C++ with Examples The setprecision() method of iomanip library in C++ is used to set the ios library floating point precision based on the precision specified as the parameter to this method. Syntax: setprecision(int n) Parameters: This method accepts n as a parameter which is the integer argument corresponding to wh 2 min read Like