c++ - Bit manipulation tilde -
i understand tilde flips every bits, if int num = ~0
why result num = -1
, neither max value of int
or unsigned int
?
but max value of unsigned
:
#include <iostream> #include <limits> int main() { std::cout << ( unsigned(-1) == std::numeric_limits<unsigned>::max() ) << std::endl; return 0; }
Comments
Post a Comment