Use the symbolic constants in the header file Cfloat to learn the range of table numbers for floating-point type data---gyy finishing

Source: Internet
Author: User

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
  1. #include <iostream>
  2. #include <cfloat>
  3. Using namespace std;
  4. int main ()
  5. {
  6. cout << "Size:" << Endl;
  7. cout << "float is" << sizeof (float) << "bytes." << Endl;
  8. cout << "Double is" << sizeof (double) << "bytes." << Endl;
  9. cout << "long Double is" << sizeof (long double) << "bytes." << Endl       << Endl;
  10. cout << "Bits per byte =" << char_bit << endl << Endl;
  11. cout << "Maximum values:" << Endl;
  12. cout << "float:" << flt_max << Endl;
  13. cout << "double:" << Dbl_max << Endl;
  14. cout << "Minimum values:" << Endl;
  15. cout << "float:" << flt_min << Endl;
  16. cout << "double:" << dbl_min << Endl;
  17. System ("pause");
  18. return 0;
  19. }


Run results


[CPP]View PlainCopy
  1. #include <iostream>
  2. #include <cfloat>
  3. Using namespace std;
  4. int main ()
  5. {
  6. //floating-point number in-memory storage size (bytes)
  7. cout << "floating-point number storage in memory size (bytes):" << Endl;
  8. cout << "float is" << sizeof (float) << "bytes." << Endl;
  9. cout << "Double is" << sizeof (double) << "bytes." << Endl;
  10. cout << "long Double is" << sizeof (long double) << "bytes." << Endl       << Endl;
  11. cout << "Bits per byte =" << char_bit << endl << Endl;
  12. //maximum value of floating-point number
  13. cout << "Maximum number of floating point numbers:" << Endl;
  14. cout << "float:" << flt_max << Endl;
  15. cout << "double:" << Dbl_max << Endl;
  16. minimum value of//floating-point number
  17. cout << "minimum value of floating point:" << Endl;
  18. cout << "float:" << flt_min << Endl;
  19. cout << "double:" << dbl_min << Endl;
  20. //floating-point accuracy
  21. cout << "accuracy of floating point numbers:" << Endl;
  22. cout << "float:" <<flt_dig << Endl;
  23. cout << "double:" << dbl_dig << Endl;
  24. Binary significant digits of the//floating-point number (number of digits in Mantissa, including sign bit)
  25. cout << "binary significant digits of the floating-point number (number of digits in the mantissa, including the sign bit):" << Endl;
  26. cout << "float:" <<flt_mant_dig << Endl;
  27. cout << "double:" << dbl_mant_dig << Endl;
  28. //index maximum of binary floating-point number
  29. cout << "exponential maximum of binary floating-point number:" << Endl;
  30. cout << "float:" << flt_max_exp << Endl;
  31. cout << "double:" << dbl_max_exp << Endl;
  32. //index minimum of binary floating-point number
  33. cout << "exponential minimum of binary floating-point number:" << Endl;
  34. cout << "float:" << flt_min_exp << Endl;
  35. cout << "double:" << dbl_min_exp << Endl;
  36. exponential maximum of the//decimal floating-point number
  37. cout << "exponential maximum of decimal floating-point number:" << Endl;
  38. cout << "float:" << flt_max_10_exp << Endl;
  39. cout << "double:" << dbl_max_10_exp << Endl;
  40. exponential minimum of the//decimal floating-point number
  41. cout << "exponential minimum of decimal floating-point number:" << Endl;
  42. cout << "float:" << flt_min_10_exp << Endl;
  43. cout << "double:" << dbl_min_10_exp << Endl;
  44. System ("pause");
  45. return 0;
  46. }


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.