c***g 发帖数: 472 | 1 what's the different between
n >> 1;
and
n >>= 1;
I am quite confused about this |
d**e 发帖数: 6098 | 2 the second one should be like
a = n >> 1;
n = a;
【在 c***g 的大作中提到】 : what's the different between : n >> 1; : and : n >>= 1; : I am quite confused about this
|
z****4 发帖数: 194 | 3 第二个需要temporary memory?
【在 c***g 的大作中提到】 : what's the different between : n >> 1; : and : n >>= 1; : I am quite confused about this
|
p*i 发帖数: 411 | 4 n >> 1 is an expression that does not change the value of n.
n >>= 1 is equivalent to n = n >> 1, which basically assigns the result of
the expression (n>>1) back to n
At the machine level, "n>>=1" can be a single instruction (depending the
instruction set)
n >> 1 may need temporary storage. again, these stuff heavily depend on the
architecture and the instruction set.
【在 c***g 的大作中提到】 : what's the different between : n >> 1; : and : n >>= 1; : I am quite confused about this
|