c 中的结果翻转为负数

the result in c flipped to negative number

 unsigned int x;
 unsigned int y;
 x = 0x66;
 y = 0x39;
 unsigned z;
 z =  ~x | ~y;
 printf("%d\n",z);

我的代码是这样的,我想计算 ~x | ~y,我把z定义为无符号的,但是z还是负数。为什么?这是 ~x 中的问题吗,那么计算机中的 ~x 操作是什么。 谢谢

你告诉 printf 打印一个带符号的输入,所以它会相应地解释它的输入。试试 printf("%u\n", z);.