0

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?

DoReMi
  • 221
  • 1
  • 6

1 Answers1

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;
}

http://ideone.com/y4JuFe

rici
  • 234,347
  • 28
  • 237
  • 341