一的補數(ones' complement),計算機專業術語,一補數用於代數補算。
基本介紹
- 中文名:一的補數
- 外文名:ones' complement
- 別名:一補數
- 所屬領域:計算機
- 作用:代數運算
基本解釋,定義,性質,求法,
基本解釋
一個數的一的補數(one's complement)在很多算術運算中的表現與這個數的相反數很相似,此特性可使加法電路同時可以運算減法。然而,由於一的補數中存在很多問題,一的補數並未像二的補數(two's complement,即常說的補碼)一樣被廣泛套用。
定義
中文定義:
將包括符號位的二進制整數反轉,得到的數即為原二進制數的一的補數(ones' complement)。
英文定義:
Theones' complementof abinary numberis defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0s for 1s and vice versa). The ones' complement of the number then behaves like the negative of the original number in some arithmetic operations. To within a constant (of −1), the ones' complement behaves like the negative of the original number withbinary addition. However, unliketwo's complement, these numbers have not seen widespread use because of issues such as the offset of −1, that negating zero results in a distinct negative zerobit pattern, less simplicity with arithmeticborrowing, etc.
Aones' complement systemorones' complement arithmeticis a system in which negative numbers are represented by the inverse of the binary representations of their corresponding positive numbers. In such a system, a number is negated (converted from positive to negative or vice versa) by computing its ones' complement. An N-bit ones' complement numeral system can only represent integers in the range −(2−1) to 2−1 whiletwo's complementcan express −2to 2−1.
Theones' complement binarynumeral systemis characterized by thebit complementof any integer value being the arithmetic negative of the value. That is, inverting all of the bits of a number (the logical complement) produces the same result as subtracting the value from 0.
Many early computers, including theCDC 6600, theLINC, thePDP-1, and the UNIVAC 1107, use ones' complement notation; the descendants of the UNIVAC 1107, theUNIVAC 1100/2200 series, continue to use it, but the majority of current computers use two's complement.
性質
一、正整數的一的補數為原二進制編碼。
二、0的一的補數為原二進制碼或反轉後的二進制碼。
求法
一、正整數
正整數的一的補數為原二進制碼。
二、負整數
將二進制數反轉(包括符號位),得到的數即為原二進制的一的補數(ones' complement)。若某一位為0,則使其變為1,反之亦然。
例如,+3是0011,以一的補碼錶示-3便是1100。
+2是0010,以一的補碼錶示-2便是1101。
三、表示方式
下表列出了4-bit二進數所能表示的整數。