what's the different between n >> 1; and n >>= 1; I am quite confused about this
d*e
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
3 楼
第二个需要temporary memory?
【在 c***g 的大作中提到】 : what's the different between : n >> 1; : and : n >>= 1; : I am quite confused about this
p*i
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