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 为什么结果是,既不是ornum = -1的最大值?intunsigned 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