s*********e 发帖数: 145 | 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. |
b******a 发帖数: 215 | 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.
|
s*********e 发帖数: 145 | 3 why use "-2"? what is -2?
thanks
【在 b******a 的大作中提到】 : a&-2 will clear a's LSB,so a will be even number. : : that
|
b******a 发帖数: 215 | 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
|
h**p 发帖数: 377 | 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
|
X****r 发帖数: 3557 | 6 不是~2,就是-2。-2 == ~1
【在 h**p 的大作中提到】 : 是不是~2?
|
m******s 发帖数: 612 | 7 -2=...11111110, it is 2's complement, so this actually make it even |