二进制文件签名_二进制数的签名表示
二進(jìn)制文件簽名
Prerequisite: Number systems
先決條件: 數(shù)字系統(tǒng)
Until now, we have only talked about positive numbers and have already discussed their mathematical operations. But there also exists negative numbers in the number system, in this article we are going to learn about how to represent negative numbers in the binary format?
到目前為止,我們僅討論正數(shù),并且已經(jīng)討論了它們的數(shù)學(xué)運(yùn)算。 但是數(shù)字系統(tǒng)中也存在負(fù)數(shù),在本文中,我們將學(xué)習(xí)如何用二進(jìn)制格式表示負(fù)數(shù)?
簽名號(hào)碼 (Signed Numbers)
In decimal number system, we have (+) sign to represent the positive number and (-) sign to represent a negative number. But in digital logic, we have two symbols 0 and 1, so we use these symbols to represent the sign of the number.
在十進(jìn)制數(shù)字系統(tǒng)中,我們用( + )號(hào)代表正數(shù),用( - )號(hào)代表負(fù)數(shù)。 但是在數(shù)字邏輯中,我們有兩個(gè)符號(hào)0和1 ,因此我們使用這些符號(hào)來(lái)表示數(shù)字的符號(hào) 。
There are two ways of representing signed numbers,
有兩種表示帶符號(hào)的數(shù)字的方式 ,
Signed Magnitude Form
簽名幅度表
Complement Form
補(bǔ)表
1)簽署幅度表 (1) Signed Magnitude Form)
In signed magnitude form, an additional bit is placed to the extreme left (MSB) of the number to represent the sign; thus, it is known as the sign bit.
在帶符號(hào)的幅度形式中,在數(shù)字的最左端(MSB)處放置一個(gè)附加位來(lái)表示符號(hào)。 因此,它被稱為符號(hào)位。
We use 0 to represent the positive numbers and 1 to represent the negative numbers. The extra bit is isolated from the magnitude of binary numbers using a comma.
我們用0代表正數(shù),用1代表負(fù)數(shù)。 使用逗號(hào)將多余的位與二進(jìn)制數(shù)的大小隔離。
Under the signed-magnitude system, a great amount of manipulation is required to add a positive number to a negative number. Thus, representation is possible but still, it is impractical in nature.
在有符號(hào)幅度系統(tǒng)下,需要大量的操作才能將正數(shù)添加到負(fù)數(shù)。 因此,表示是可能的,但在本質(zhì)上仍然是不切實(shí)際的。
Example1: Represent 13 and -13 in signed magnitude form
示例1:以帶符號(hào)的幅度形式表示13和-13
Solution:
解:
(13)10 = (0,1101)2 sign-bit 0 is used to represent the positive number(-13)10 = (1,1101)2 sign-bit 1 is used to represent the negative numberComplement Form: Since performing arithmetic operations using a signed magnitude form is very complex. Digital computers use the complement form to perform these calculations.
補(bǔ)碼形式:由于使用帶符號(hào)的幅度形式執(zhí)行算術(shù)運(yùn)算非常復(fù)雜。 數(shù)字計(jì)算機(jī)使用補(bǔ)碼形式來(lái)執(zhí)行這些計(jì)算。
There are two complement forms - 1's complement form and 2's complement form.
有兩種補(bǔ)碼形式-1的補(bǔ)碼形式和2的補(bǔ)碼形式。
If the number is positive then, the magnitude is represented in its true binary form and a sign bit 0 is added to the LHS of the MSB. For a positive number, the representation is the same in signed magnitude, 1's and 2's complement form.
如果該數(shù)字為正,則以其真正的二進(jìn)制形式表示幅度,并將符號(hào)位0添加到MSB的LHS。 對(duì)于正數(shù),表示形式在帶符號(hào)的幅度,1和2的補(bǔ)碼形式上相同。
The advantage of using a complement form to perform arithmetic operations is the reduction in the hardware. Instead, of having separate hardware for addition and subtraction only additional adders are needed.
使用補(bǔ)碼形式執(zhí)行算術(shù)運(yùn)算的優(yōu)點(diǎn)是減少了硬件。 取而代之的是,沒(méi)有用于加法和減法的單獨(dú)硬件,僅需要附加的加法器。
1的補(bǔ)碼表示 (1's Complement Representation)
The 1's complement of a number can be obtained by replacing each "0 bit with 1 bit" and "1 bit with 0 bit" in the binary number.
可以通過(guò)將二進(jìn)制數(shù)中的每個(gè)“ 0位加1位”和“ 1位加0位”替換來(lái)獲得數(shù)字的1的補(bǔ)碼。
Example: Represent (-15)10 in its 1's complement form
示例:以其1的補(bǔ)碼形式表示(-15) 10
Solution:
解:
(15)10 in binary form can be represented as (1111)2.
(15) 10的二進(jìn)制形式可以表示為(1111) 2 。
Now, to represent its negative sign, we will add a sign bit 1.
現(xiàn)在,為了表示它的負(fù)號(hào),我們將添加一個(gè)符號(hào)位1。
Thus, (-15)10 = (1,1111)2. To represent it in 1's complement form, we will replace each 1 with 0 (excluding the sign bit, because if we replace sign bit then its sign will be changed to positive which is not correct). Therefore,
因此,(-15) 10 =(1,1111) 2 。 為了用1的補(bǔ)碼形式表示它,我們將每個(gè)1替換為0(不包括符號(hào)位,因?yàn)槿绻鎿Q符號(hào)位,則其符號(hào)將變?yōu)檎龜?shù),這是不正確的)。 因此,
2的補(bǔ)碼表示 (2's Complement Representation)
We can get the 2's complement of a number by finding the 1's complement of number and adding 1 to the LSB of the respective 1's complement.
我們可以通過(guò)找到數(shù)字的1的補(bǔ)碼并將1加到相應(yīng)的1的補(bǔ)碼的LSB上來(lái)獲得數(shù)字的2的補(bǔ)碼。
Example: Represent (-15)10 in its 2's complement form.
示例:以2的補(bǔ)碼形式表示(-15) 10 。
Solution:
解:
As we have discussed above, the 1's complement representation of (-15)10 is given as 10000. Now, we have to add a bit 1 to the LSB in the above 1's complement form i.e., we will get,
如上所述,(-15) 10的1的補(bǔ)碼表示為10000 。 現(xiàn)在,我們必須以上述1的補(bǔ)碼形式在LSB上加一位,即,
Which is the required 2's complement representation of (-15)10.
這是(-15) 10的必填2的補(bǔ)碼表示形式。
Example: Represent (-51)10 in its signed magnitude, 1's complement and 2's complement form.
示例:以(-51) 10的有符號(hào)幅度,1的補(bǔ)碼和2的補(bǔ)碼形式表示。
Solution:
解:
翻譯自: https://www.includehelp.com/basics/signed-representation-of-binary-numbers.aspx
二進(jìn)制文件簽名
總結(jié)
以上是生活随笔為你收集整理的二进制文件签名_二进制数的签名表示的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c# 整数类型转byte_C#中数据类型
- 下一篇: 索尼70200f4停产了吗