Range of values overflow and underflow
What is the largest integer value that can be expressed in 32 bits?
- How to calculate range?
- [0…(2n – 1)]
- For 2 bits?
- 8 bits?
- For 32-bit computers
from 0 to 4,294,967,295
- For 32-bit computers
- Integer range is from -2,147,483,648 to 2,147,483,647
- Integer overflow and underflow
What will be the output?
int a=2147483647;
cout<<++a;
int a=-2147483648;
cout<<a–;
cout<<” “<<a;
What will be the output?
int a=2147483647;
cout<<++a; //-2147483648 overflow
int a=-2147483648;
cout<<a–; //-2147483648
cout<<” “<<a; //2147483647 underflow