Use symbolic constants in header file Cfloat to learn the range of table numbers for floating-point type data
Cfloat header file contains the length limit of the floating-point number of the system
The symbolic constants in the header file Climits are the range of table numbers that are known to the integer data, and cannot get the range of table numbers for floating-point type data.
<climits> The header file contains the system's integer length limit, which has replaced the header file <limits.h>
<cfloat> The header file contains the system's floating-point length limit, which replaces the header file <float.h>
<cfloat> the value and meaning of each character constant of the header file
The symbolic constants used to define the size of floating-point numbers in a program are as follows
flt_min float Type the smallest positive number
Flt_max float Type the largest positive number
Dbl_min the smallest positive number of the double type
Dbl_max the largest positive number of type double
? Flt_mant_dig binary significant digits of type float
DBL _mant_dig binary significant digits of type double
? Flt_dig Float type accuracy
Dbl_dig Double Type the Accuracy
Flt_min_exp the minimum exponent of float type binary floating-point number
Flt_max_exp Float maximum exponent of binary floating-point number
Dbl_min_exp minimum exponent of double binary floating-point number
Dbl_max_exp maximum exponent of double binary floating-point numbers
Flt_min_10_exp minimum exponent of float type decimal floating-point number
Flt_max_10_EXP float type decimal floating point maximum exponent
Dbl_min_10_EXP Double decimal floating-point number minimum exponent
Dbl_max_10_EXP Double decimal floating-point number maximum exponent
[CPP]View PlainCopy
- #include <iostream>
- #include <cfloat>
- Using namespace std;
- int main ()
- {
- cout << "Size:" << Endl;
- cout << "float is" << sizeof (float) << "bytes." << Endl;
- cout << "Double is" << sizeof (double) << "bytes." << Endl;
- cout << "long Double is" << sizeof (long double) << "bytes." << Endl << Endl;
- cout << "Bits per byte =" << char_bit << endl << Endl;
- cout << "Maximum values:" << Endl;
- cout << "float:" << flt_max << Endl;
- cout << "double:" << Dbl_max << Endl;
- cout << "Minimum values:" << Endl;
- cout << "float:" << flt_min << Endl;
- cout << "double:" << dbl_min << Endl;
- System ("pause");
- return 0;
- }
Run results
[CPP]View PlainCopy
- #include <iostream>
- #include <cfloat>
- Using namespace std;
- int main ()
- {
- //floating-point number in-memory storage size (bytes)
- cout << "floating-point number storage in memory size (bytes):" << Endl;
- cout << "float is" << sizeof (float) << "bytes." << Endl;
- cout << "Double is" << sizeof (double) << "bytes." << Endl;
- cout << "long Double is" << sizeof (long double) << "bytes." << Endl << Endl;
- cout << "Bits per byte =" << char_bit << endl << Endl;
- //maximum value of floating-point number
- cout << "Maximum number of floating point numbers:" << Endl;
- cout << "float:" << flt_max << Endl;
- cout << "double:" << Dbl_max << Endl;
- minimum value of//floating-point number
- cout << "minimum value of floating point:" << Endl;
- cout << "float:" << flt_min << Endl;
- cout << "double:" << dbl_min << Endl;
- //floating-point accuracy
- cout << "accuracy of floating point numbers:" << Endl;
- cout << "float:" <<flt_dig << Endl;
- cout << "double:" << dbl_dig << Endl;
- Binary significant digits of the//floating-point number (number of digits in Mantissa, including sign bit)
- cout << "binary significant digits of the floating-point number (number of digits in the mantissa, including the sign bit):" << Endl;
- cout << "float:" <<flt_mant_dig << Endl;
- cout << "double:" << dbl_mant_dig << Endl;
- //index maximum of binary floating-point number
- cout << "exponential maximum of binary floating-point number:" << Endl;
- cout << "float:" << flt_max_exp << Endl;
- cout << "double:" << dbl_max_exp << Endl;
- //index minimum of binary floating-point number
- cout << "exponential minimum of binary floating-point number:" << Endl;
- cout << "float:" << flt_min_exp << Endl;
- cout << "double:" << dbl_min_exp << Endl;
- exponential maximum of the//decimal floating-point number
- cout << "exponential maximum of decimal floating-point number:" << Endl;
- cout << "float:" << flt_max_10_exp << Endl;
- cout << "double:" << dbl_max_10_exp << Endl;
- exponential minimum of the//decimal floating-point number
- cout << "exponential minimum of decimal floating-point number:" << Endl;
- cout << "float:" << flt_min_10_exp << Endl;
- cout << "double:" << dbl_min_10_exp << Endl;
- System ("pause");
- return 0;
- }
Run results
Use the symbolic constants in the header file Cfloat to learn the range of table numbers for floating-point type data---gyy finishing