&安培;&QUOT有关运营商QUOT问题; [英] questions about operator "&"

查看:128
本文介绍了&安培;&QUOT有关运营商QUOT问题;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有错题,但我不知道如何来形容了。

Probably have wrong title,but I don't know how to describe it.

int x=0x4a;
h=!(0x80000000000&(0x39+(~x+1)));

结果为h = 0。
现在的问题是x具有32位,而0x80000000000有超过32位。如果我设置变量i 0x80000000000并打印为十六进制格式,它会显示0。所以在这种情况下,为什么不h的结果是1,因为0x80000000000变为0?

the result is h=0. The question is x has 32 bits, while 0x80000000000 has more than 32 bit. If I set variable i to 0x80000000000 and print it as hex format,it will show 0. So in that case, why not the result of h is 1 because 0x80000000000 turns to be 0?

我使用的语言是C

推荐答案

0x8000000000是得到long long int 不变。因此,C编译器促进各类算术前pression到前pression内出现的最高precision。

0x8000000000 is a long long int constant. Therefore the C compiler promotes the types in an arithmetic expression to the highest precision that occurs within an expression.

如果相反,你写道:

  int x=0x4a;
  int h1=(0x80000000000&(0x39+(~x+1)));
  int h = !h1;

然后 ^ h 将成为1.也许失踪precision警告将印发

Then h would become 1. And perhaps a warning on missing precision would be issued.

这篇关于&安培;&QUOT有关运营商QUOT问题;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆