Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- using namespace std;
- int main() {
- int n = INT_MIN;
- int p = -n;
- uint32_t up = -n;
- uint64_t up2 = -n;
- cout << "n: " << n << endl;
- cout << "p: " << p << " up: " << up << " up2: " << up2 << endl;
- return 0;
- }
- Result:
- n: -2147483648
- p: -2147483648 //because -INT_MIN = INT_MIN for signed integer
- up: 2147483648 //because up is unsigned int from 0 to 4,294,967,295 (2^32 − 1)
- up2: 18446744071562067968 //Question here. WHY up2 != up (2147483648)???
- n = 0x80000000
- p=0x80000000
- up=0x80000000
- up2=0xFFFFFFFF80000000
Add Comment
Please, Sign In to add comment