avatar
what does "a & -2" mean?# Programming - 葵花宝典
s*e
1
dear people,
if a is an integer, what would "a & -2" mean? It was used to make sure that
the result can be divided by 2, but i dont understand.
thanks.
avatar
b*a
2
a&-2 will clear a's LSB,so a will be even number.

that

【在 s*********e 的大作中提到】
: dear people,
: if a is an integer, what would "a & -2" mean? It was used to make sure that
: the result can be divided by 2, but i dont understand.
: thanks.

avatar
s*e
3
why use "-2"? what is -2?
thanks

【在 b******a 的大作中提到】
: a&-2 will clear a's LSB,so a will be even number.
:
: that

avatar
b*a
4
if you dont know what your machine type, see it is 16bit or 32 bit. you
can not define the second operator. but use -2 you can always get the ri
ght formate as 0xFFFE for 16bit, 0xFFFF FFFE for 32 bit systme

【在 b******a 的大作中提到】
: a&-2 will clear a's LSB,so a will be even number.
:
: that

avatar
h*p
5
是不是~2?

【在 b******a 的大作中提到】
: if you dont know what your machine type, see it is 16bit or 32 bit. you
: can not define the second operator. but use -2 you can always get the ri
: ght formate as 0xFFFE for 16bit, 0xFFFF FFFE for 32 bit systme

avatar
X*r
6
不是~2,就是-2。-2 == ~1

【在 h**p 的大作中提到】
: 是不是~2?
avatar
m*s
7
-2=...11111110, it is 2's complement, so this actually make it even
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。