Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
チルダがすべてのビットを反転することは理解していますが、そうすると、結果が 、またはの最大値のどちらでもないのはint num = ~0 なぜですか?num = -1intunsigned int
int num = ~0
num = -1
int
unsigned int
しかし、それは の最大値ですunsigned:
unsigned
#include <iostream> #include <limits> int main() { std::cout << ( unsigned(-1) == std::numeric_limits<unsigned>::max() ) << std::endl; return 0; }
http://ideone.com/y4JuFe