#include #include #include using namespace std; int main() { unsigned char ch; unsigned long long int bigNumber{0}; cout << "\tThe size of a char is " << sizeof(char) << endl; cout << "\tThe size of a char is " << sizeof(ch) << endl; cout << "\tThe size of a short is " << sizeof(short) << endl; cout << "\tThe size of a int is " << sizeof(int) << endl; cout << "\tThe size of a long is " << sizeof(long) << endl; cout << "\tThe size of a long long is " << sizeof(bigNumber) << endl; cout << "\tThe size of a long long is " << sizeof(long long) << endl; cout << endl; // powers of two. for(int i = 1; i < 65; ++i) { bigNumber = bigNumber * 2 + 1; cout << "\t2^" << i << " - 1 = " << setw(20) << bigNumber << endl; } cout << endl; // limits numeric_limitsintInfo; cout << "The smallest int is " << intInfo.min() << endl; cout << "The largest int is " << intInfo.max() << endl; // overflow cout << bigNumber << " + 1 = " << bigNumber+1 << endl; // literals cout << endl << endl; int i { 020}; cout << "020 = " << i << endl; i = 0x20; cout << "0x20 = " << i << endl; i = 0Xf; cout << "0Xf = " << i << endl; i = 0b01111111'11111111'11111111'11111111; cout << "0b01111111'11111111'11111111'11111111 = " << i << endl; cout << endl << endl; // some more overflow i = 0b10000000'00000000'00000000'00000000; cout << "0b10000000'00000000'00000000'00000000 = " << i << endl; cout << endl; int k{i+1}; cout << i << " + 1 = " << k << endl; cout << "In hex: " << hex; cout << i << " + 1 = " << k << endl; cout << "In octal: " << oct; cout << i << " + 1 = " << k << endl; cout << dec; cout << endl << endl; // narrowing long long j{10'000'000'000'000}; // i = j; i = static_cast(j); cout << " j = " << j << " and i = " << i << endl; // widening no problem j = i; return 0; }