Reputation: 221
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
?
Upvotes: 0
Views: 103
Reputation: 241691
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;
}
Upvotes: 1