二的补码,为什么叫“二"? [英] two's complement, why the name "two"

查看:20
本文介绍了二的补码,为什么叫“二"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道无符号,二进制补码,一个的补码和符号幅度,以及它们之间的区别,但我很好奇的是:

i know unsigned,two's complement, ones' complement and sign magnitude, and the difference between these, but what i'm curious about is:

  1. 为什么叫二(或一)补码,那么有没有更广义的 N 补码?
  2. 这些天才是通过什么方式演绎出如此自然的方式来表示负数的?

推荐答案

当有人通过从 0 中减去 1 并让位滚动实际上使有符号算术更简单,因为不必进行特殊检查来检查数字是否为负.其他解决方案会在 -10 之间产生不连续性.二进制补码的唯一奇怪之处在于,在你的范围内你得到的负数比你得到的正数多一个.但是,其他解决方案会给你一些奇怪的东西,比如 +0-0.

Two's complement came about when someone realized that 'going negative' by subtracting 1 from 0 and letting the bits rollunder actually made signed arithmetic simpler because no special checks have to be done to check if the number is negative or not. Other solutions give you a discontinuity between -1 and 0. The only oddity with two's complement is that you get one more negative number in your range than you have positive numbers. But, then, other solutions give you strange things like +0 and -0.

根据维基百科,该名称本身来自数学,并且基于在数量有限的情况下使减法更简单的方法.该系统实际上是一个基数补码",并且由于二进制是以二为底的,这成为二进制补码".原来一个补码"是以减基数补码"命名的,也就是基数减一.如果您将其视为十进制,则名称背后的含义会更有意义.

According to Wikipedia, the name itself comes from mathematics and is based on ways of making subtraction simpler when you have limited number places. The system is actually a "radix complement" and since binary is base two, this becomes "two's complement". And it turns out that "one's complement" is named for the "diminished radix complement", which is the radix minus one. If you look at this for decimal, the meanings behind the names makes more sense.

补充方法(维基百科)

这篇关于二的补码,为什么叫“二"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆