Here we will try to understand Methods for Representation of Negative Numbers in Binary Understanding.
For example, consider the decimal number +9.
What is the binary equivalent of 9?
The binary equivalent of 9 is 1001.
How to represent -9 in binary?
The negative or signed numbers should also have a representation in the binary.
Before understanding the methods of representing binary numbers we will understand a bit about components of a computer and how the data unit will be stored and processed on a computer.
Whenever we buy a computer we will ask for a 64-bit or a 32-bit computer.
What does a 64-bit or a 32-bit computer mean?
The components of the computer like ALU, Registers, Address Bus, and Databus are used to store or process a 64-bit or 32-bit data unit.
For example, Assume an 8-bit computer which is not practically available.
On this 8-bit register if we want to store a binary value of 9, how it will be represented is as shown in the image below.
Even though four bits are sufficient to represent 1001 because the register is an 8-bit register we use the remaining bits with 0 as shown in the image below.
Similarly, to represent 1001 on a 64-bit computer 1001 is preceded by 60 o's.
Methods for Representation of Negative Numbers in Binary
Negative numbers in binary can be represented in 3 ways.
1. Sign Magnitude Method.
2. 1's Complement Method.
3. 2's Complement Method.
For all these methods we will assume an 8-bit register.
In all these methods the MSB is used for sign bit and remaining bits are used for the magnitude of the binary number as shown in the image below.
Sign Magnitude Method:
In the Sign Magnitude method, an additional bit called sign bit is placed in front of the number.
If the sign bit 0, the number is positive.
If the sign bit 1, the number is negative.
In the sign-magnitude representation if we try to represent +9 the sign bit will be zero and the magnitude is 0001001 as shown in the image below.
If we try to represent -9 the sign bit will be one and the magnitude is 0001001 as shown in the image below.
1's Complement Method:
In 1's Complement Method, if the number is positive the magnitude is represented in its true binary form and sign 0 is placed in front of MSB.
For example, if we try to represent +9 the sign bit will be zero and the magnitude is 0001001 [It's a true binary form ] as shown in the image below.
If we try to represent -9 the sign bit will be one and the magnitude is 1110110 [ 1's complement of 0001001 ] as shown in the image below.
2's Complement Method:
In 2's Complement Method, if the number is positive the magnitude is represented in its true binary form, and sign 0 is placed in front of MSB.
For example, if we try to represent +9 the sign bit will be zero and the magnitude is 0001001 [It's a true binary form ] as shown in the image below.
If we try to represent -9 the sign bit will be one and the magnitude is 1110111 [ 2's complement of 0001001 ] as shown in the image below.
Link for playlists:
[ Ссылка ]
Link for our website: [ Ссылка ]
Follow us on Facebook @ [ Ссылка ]
Follow us on Instagram @ [ Ссылка ]
Follow us on Twitter @ [ Ссылка ]
Mail us @ learningmonkey01@gmail.com
Ещё видео!