Use symbolic constants in header file Climits to learn the range of table numbers for integer data---gyy finishing

Source: Internet
Author: User

The various symbolic constants are defined in the header file Climits (limits.h) in a macro definition to represent the range of various integer type representations, such as the maximum minimum value of int, the maximum minimum value of long, and so on.

Symbolic constants

Said

Char_bit

The number of bits of char

Char_max

Maximum value of Char

Char_min

Minimum value of Char

Schar_max

Maximum value of signed Char

Schar_min

Signed minimum value of Char

Uchar_max

Maximum value of unsigned char

Shrt_max

The maximum value of short

Shrt_min

Minimum value of short

Ushrt_max

Unsigned the maximum value of short

Int_max

The maximum value of int

Int_min

The minimum value of int

Unit_max

Maximum value of unsigned int

Long_max

The maximum value of long

Long_min

The minimum value of long

Long_max

Unsigned the maximum value of long

[CPP]View PlainCopy
  1. #include <iostream>
  2. #include <climits>
  3. Using namespace std;
  4. int main ()
  5. {
  6. cout << "Size:" << Endl;
  7. cout << "int is" << sizeof (int) << "bytes." << Endl;
  8. cout << "short are" << sizeof (short) << "bytes." << Endl;
  9. cout << "Long is" << sizeof (long) << "bytes." << Endl << Endl;
  10. cout << "Bits per byte =" << char_bit << endl << Endl;
  11. cout << "Maximum values:" << Endl;
  12. cout << "int:" << int_max << Endl;
  13. cout << "short:" << shrt_max << Endl;
  14. cout << "long:" << Long_max << Endl;
  15. cout << "char:" << char_max << Endl;
  16. cout << "signed char:" << schar_max << Endl;
  17. cout << "unsigned int:" << uint_max << Endl;
  18. cout << "unsigned short:" << ushrt_max << Endl;
  19. cout << "unsigned long:" << Ulong_max << Endl;
  20. cout << "unsigned char:" << uchar_max << endl << Endl;
  21. cout << "Minimum values:" << Endl;
  22. cout << "int:" << int_min << Endl;
  23. cout << "short:" << shrt_min << Endl;
  24. cout << "long:" << long_min <<endl;
  25. cout << "char:" << char_min <<endl;
  26. cout << "signed char:" << schar_min <<endl;
  27. System ("pause");
  28. return 0;
  29. }



Run results

The result is consistent with the subscript.

Note: 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.

<cfloat> The header file contains the system's floating-point length limit, which replaces the header file <float.h>
<climits> The header file contains the system's integer length limit, which has replaced the header file <limits.h>

Use symbolic constants in header file Climits to learn the range of table numbers for integer 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.