由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - what does "a & -2" mean?
相关主题
包子现金求助关于68k assembly问题[转载] CS Algorithm Interview question
谁帮我解释一下这个代码 几道 google interview 的题目
C 语言,数字变字符,有点难度贡献一下:本版上搜集的 Google 面试题 (转载)
一个哈希表问题what does this mean?
Check if the sum of two integers in an integer array eqauls to the given number find the subarray
面试题 -算法?Interview question
两道M软件大公司的最新面世算法题 (转载)求助一个数据结构的求时间复杂度问题
居然有正负零一个数据结构中的数学求和问题求教 (转载)
相关话题的讨论汇总
话题: what话题: mean话题: does话题: dont话题: divided
进入Programming版参与讨论
1 (共1页)
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
1 (共1页)
进入Programming版参与讨论
相关主题
一个数据结构中的数学求和问题求教 (转载)Check if the sum of two integers in an integer array eqauls to the given number
how to get division and reminder in one operation?面试题 -算法?
来来来,我也问个题 (转载)两道M软件大公司的最新面世算法题 (转载)
HOW TO round float numbers to integer? in C居然有正负零
包子现金求助关于68k assembly问题[转载] CS Algorithm Interview question
谁帮我解释一下这个代码 几道 google interview 的题目
C 语言,数字变字符,有点难度贡献一下:本版上搜集的 Google 面试题 (转载)
一个哈希表问题what does this mean?
相关话题的讨论汇总
话题: what话题: mean话题: does话题: dont话题: divided