I understand that tilde flips every bits, but if I do int num = ~0
Why the result is num = -1
, neither max value of int
or unsigned int
?
Asked
Active
Viewed 102 times
1 Answers
1
But it is the max value of unsigned
:
#include <iostream>
#include <limits>
int main() {
std::cout << ( unsigned(-1) == std::numeric_limits<unsigned>::max() )
<< std::endl;
return 0;
}

rici
- 234,347
- 28
- 237
- 341
-
But if I do int unsigned int num = ~0, the result is num = 4294967295, I think this shall be the max of unsigned int – DoReMi Oct 07 '13 at 00:19
-
1