avatar
问个简单问题# Java - 爪哇娇娃
g*y
1
6>>2 = 1
为什么 -6>>2 = -2 呢?
BTW, in Java, -1的机器内码是:
(a) 1000 0000 0000 0001
(b) 1000 0000 0000 0000
告别考试好久了, 全忘了 :)
avatar
c*t
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
: 告别考试好久了, 全忘了 :)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。