The values of the columns Size and Range depend on the system the program is compiled for. The values shown above are those found on most 32-bit systems. But for other systems, the general specification is that int has the natural size suggested by the system architecture (one "word") and the four integer types char, short, int and long must each one be at least as large as the one preceding it, with char being always one byte in size. The same applies to the floating point types float, double and long double, where each one must provide at least as much precision as the preceding one. |
#include<iostream> #include<stdio.h> #include<math.h> #include<cmath> #include<climits> #define NUM_BITS_BYTE 8 int main() { //const int NUM_BITS_BYTE=8; //Prints the maximum signed long that can be represented in C and C++ std::cout << "The long max in decimal is: " <<std::dec << LONG_MAX << std::endl; std::cout << "The long max in hex is: " <<std::hex << LONG_MAX << std::endl; std::cout << "And the long max in oct is: " <<std::oct << LONG_MAX << std::endl; std::cout << "The unsign long max in dec is: " <<std::dec << ULONG_MAX << std::endl; std::cout << "The unsign long max in hex is: " <<std::hex << ULONG_MAX << std::endl; std::cout << "The unsign long max in oct is: " <<std::oct << ULONG_MAX << std::endl; std::cout << "The unsigned short max in dec is: " <<std::dec << USHRT_MAX << std::endl; std::cout << "The unsigned short max in hex is: " <<std::hex << USHRT_MAX << std::endl; std::cout << "The unsigned short max in oct is: " <<std::oct << USHRT_MAX << std::endl; return 0; } |
unsigned long int unsignlong=ULONG_MAX; signed long int signlong=LONG_MAX; std::cout <<"The unsigned long is: " <<std::dec << unsignlong << std::endl; |