Guest User

Untitled

a guest
Jan 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <climits>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int n = INT_MIN;
  8. int p = -n;
  9. uint32_t up = -n;
  10. uint64_t up2 = -n;
  11.  
  12. cout << "n: " << n << endl;
  13. cout << "p: " << p << " up: " << up << " up2: " << up2 << endl;
  14. return 0;
  15. }
  16.  
  17. Result:
  18. n: -2147483648
  19. p: -2147483648 //because -INT_MIN = INT_MIN for signed integer
  20. up: 2147483648 //because up is unsigned int from 0 to 4,294,967,295 (2^32 − 1)
  21.  
  22. up2: 18446744071562067968 //Question here. WHY up2 != up (2147483648)???
  23.  
  24. n = 0x80000000
  25. p=0x80000000
  26. up=0x80000000
  27. up2=0xFFFFFFFF80000000
Add Comment
Please, Sign In to add comment