#include <iostream>
int main(int argc, const char * argv[]) {
// insert code here...
int a = -7;
unsigned b = 2;
b = a;
std::cout << b << std::endl;
return 0;
}
得到的结果是:4294967289
环境:C++、Mac OS X系统。
求解,4294967289是怎么来的?
int a = -7 = -1 - 6 = (int)0xFFFFFFFF-6 = 0xFFFFFFF9
unsigned 0xFFFFFFF9 就是4294967289了。