g**********y 发帖数: 14569 | 1 6>>2 = 1
为什么 -6>>2 = -2 呢?
BTW, in Java, -1的机器内码是:
(a) 1000 0000 0000 0001
(b) 1000 0000 0000 0000
告别考试好久了, 全忘了 :) | c*****t 发帖数: 1879 | 2
110 (base 2) >> 2 = 1
6 >> 2 is the same as 6 / 4 and round down
1111 ... 1010 >> 2 = 1111 ... 1110 = -2
-6 >> 2 is the same as -6 / 4 and round down as well :)
this is signed magnitude
no such sign system.
(c) 1111 1111 1111 1111
this is 2's compliment, the standard negative number representation.
It is 1's compliment + 1.
(d) 1111 1111 1111 1110
1's complement
(e) excess #
this one is used in exponents.
【在 g**********y 的大作中提到】 : 6>>2 = 1 : 为什么 -6>>2 = -2 呢? : BTW, in Java, -1的机器内码是: : (a) 1000 0000 0000 0001 : (b) 1000 0000 0000 0000 : 告别考试好久了, 全忘了 :)
|
|