【发布时间】:2014-05-10 18:02:45
【问题描述】:
我正在尝试做一些练习,但我被困在这一点上,我无法理解正在发生的事情,也找不到与这个特定问题相关的任何内容(找到关于逻辑运算符的其他内容,但仍然没有够了)
编辑:为什么投反对票,我很明确。没有关于 X 类型的信息,但我假设是 INT,大小也没有描述,我想通过练习我会发现。
a) At least one bit of x is '1';
b) At least one bit of x is '0';
c) At least one bit at the Least Significant Byte of x , is '1';
d) At least one bit at the Least Significant Byte of x , is '0';
我有解决方案,但如果能理解它们会很棒
a) !!x // What happens here? The '!' Usually is NOT in c
b) !!~x // Again, the '!' appears... The bitwise operand NOT is '~' and it makes the int one's complement, no further realization made unfortunately
c) !!(x & 0xFF) // I've read that this is a bit mask, i think they take in consideration 4 bytes in X, and this applies a mask at the least significant byte?
d) !!(~x & 0xFF) // Well, at this point i'm lost ...
我希望不必在大学逃课,但我全职工作以支付费用:(。
【问题讨论】:
-
x的类型是什么? -
相信我,如果有任何关于 X 类型的信息,我会说的。没有任何相关信息!
-
如果没有
!!,答案都是正确的。这表明您省略了一些问题文本。
标签: c++ c computer-science logical-operators