计算机中二进制数的表示方法都是补码吗?
绝大部分的都是。其他表示基本都已经死绝了。
■网友
正好我也在想这个问题。。。然后就开始找答案。。。发现。。。居然有两种观点(╯°口°)╯┴—┴:
好吧。。。Σ(  ̄□ ̄||)还是去书上找答案吧。。。——————————————————————————————————————————在Patterson和Hennessy老爷爷的Computer Organization and Design (Fifth Edition)中有这样的一段:
32-bit binary numbers can be represented in terms of the bit value times apower of 2:……For reasons we will shortly see, these positive numbers are called unsigned numbers.而上面的二进制表示,其实就是我们所说的原码,因此,原码用来表示unsigned numbers。接着,Patterson和Hennessy老爷爷又告诉了我们为什么要使用补码来表示signed numbers,而不是直接add a separate sign: Keep in mind that the binary bit patterns above are simply representatives of numbers. Numbers really have an infinite number of digits, with almost all being 0 except for a few of the rightmost digits. We just don’t normally show leading 0s. Hardware can be designed to add, subtract, multiply, and divide these binary bit patterns. If the number that is the proper result of such operations cannot be represented by these rightmost hardware bits, overflow is said to have occurred. It’s up to the programming language, the operating system, and the program to determine what to do if overflow occurs. Computer programs calculate both positive and negative numbers, so we need a representation that distinguishes the positive from the negative. The most obvious solution is to add a separate sign, which conveniently can be represented in a single bit; the name for this representation is sign and magnitude. Alas, sign and magnitude representation has several shortcomings. First, it’s not obvious where to put the sign bit. To the right? To the left ? Early computers tried both. Second, adders for sign and magnitude may need an extra step to set the sign because we can’t know in advance what the proper sign will be. Finally, a separate sign bit means that sign and magnitude has both a positive and a negative zero, which can lead to problems for inattentive programmers. As a result of these shortcomings, sign and magnitude representation was soon abandoned. In the search for a more attractive alternative, the question arose as to whatwould be the result for unsigned numbers if we tried to subtract a large numberfrom a small one. The answer is that it would try to borrow from a string of leading0s, so the result would have a string of leading 1s. Given that there was no obvious better alternative, the final solution was to pickthe representation that made the hardware simple: leading 0s mean positive, andleading 1s mean negative. This convention for representing signed binary numbersis called two’s complement representation(二进制的补码表示):
推荐阅读
- 有啥方法,网站,项目可以自己练习计算广告学
- 大部分黑客或安全研究员读的是啥「大学专业 」
- 在哈尔滨工业大学计算机系就读是啥样的体验
- 计算机技术与科学专业怎样利用高中毕业的暑假
- 非计算机专业想要利用课余时间深入自学C++,想要找到比较体面的工作大概需要啥水平
- 「巧克力中富含黄烷醇,能够增强脑部活动能力;因此人均巧克力消费量越高的国家,按人口平均计算的诺贝尔奖得主人数就越多。」这种说法科学么
- 有点计算机基础的人想尽快找份编程的工作。哪种编程的工作最好找还需要学些啥
- 硕士研究生选通信还是计算机视觉
- 华威大学计算机本科咋样
- 中兴努比亚 Z5 的边框到底有多窄
