简体   繁体   English

二进制表示 - 7 位二进制补码

[英]BINARY REPRESENTATION - 7 Bit two's complement

我们可以用 7 位二进制补码表示的最大负数是多少?

With 7-bits of 2's complement, it could range from -64 to 63. (traditionally, 7 bits can only go up to 2^n-1 which is 128 but MSB is reserved for sign, so we could have 6 bits to represent the data. We will be getting 64 positive and 63 negative values and answer should be -64, 63.)使用 7 位 2 的补码,它的范围可以从 -64 到 63。(传统上,7 位只能达到 2^n-1,即 128,但 MSB 保留用于符号,因此我们可以有 6 位来表示数据。我们将得到 64 个正值和 63 个负值,答案应该是 -64, 63。)

No, because in two's complement, the most significant bit is the sign bit.不,因为在二进制补码中,最高有效位是符号位。 0000001 is +1, a positive number. 0000001 是 +1,一个正数。

That is why the range of two's complement 7-bit numbers is -64 to 63, because 64 is not representable (it would be negative number otherwise).这就是为什么二进制补码 7 位数字的范围是 -64 到 63,因为 64 是不可表示的(否则它将是负数)。

The most negative number is 1000000. The leading 1 tells you it's negative, and to get the magnitude of the number, you flip all the bits (0111111), then add one (1000000 = 64).最大的负数是 1000000。前导 1 告诉您它是负数,要获得数字的大小,您需要翻转所有位 (0111111),然后加一 (1000000 = 64)。 So the resulting number is -64 thru 63.所以结果数字是 -64 到 63。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM