Monday, 31 July 2023

Digital Electronics - Binary Number Representation

 Binary Number Representation

There are 2 different kind of  binary numbers representation.

Unsigned Binary

Unsigned number contains only magnitude of the number.

Representation of Unsigned Binary

8 Bit unsigned number will be used to represent 0 to +255.

(11100101)2 =>  (1 x 20) + (0 x 21) + (1 x 22) + (0 x 23) + (0 x 24) + (1 x 25) + (1 x 26) + (1 x 27 

                    => (229)10

Signed Binary

Signed number contains both sign and magnitude of the number. MSB bit indicates the sign of the number.

Representation of  Signed Binary

There are 3 different kind of representation of Signed Binary numbers.

  1. Sign Bit Magnitude
  2. 1's complement
  3. 2's complement
Sign Bit Magnitude

In Sign-Bit Magnitude format, MSB bit will be the sign bit and other bits in the number will contribute to magnitude.
8 Bit Signed Bit magnitude number will be used to represent -127 to +127

(11100101)2 =>  (1 x 20) + (0 x 21) + (1 x 22) + (0 x 23) + (0 x 24) + (1 x 25) + (1 x 26)  

                    => (-101)10

(00000101)2 => (1 x 20) + (0 x 21) + (1 x 22) + (0 x 23) + (0 x 24) + (0 x 25) + (0 x 26

                    => (+5)10


1's Complement

For positive numbers  1's complement form will remain same as sign bit magnitude.
Only for negative numbers, all the bits including sign bit will get inverted.

8 Bit 1's complement number will be used to represent -127 to +127

(11100101)2 =>  00011010 => (0 x 20) + (1 x 21) + (0 x 22) + (1 x 23) + (1 x 24) + (0 x 25) + (0 x 26) + (0 x 27 

                    => (-26)10

(00000101)2 => (1 x 20) + (0 x 21) + (1 x 22) + (0 x 23) + (0 x 24) + (0 x 25) + (0 x 26) + (0 x 27 

                    => (+5)10

2's Complement

For positive numbers  2's complement form will remain same as sign bit magnitude.
Only for negative numbers, all the bits including sign bit will get inverted and get added with 1'b1.

8 bit signed binary number will be used to represent -128 to +127.

(11100101)2 =>  (1 x 20) + (0 x 21) + (1 x 22) + (0 x 23) + (0 x 24) + (1 x 25) + (1 x 26) + ((-1) x 27 

                    => (-27)10

(00001101)2 => (1 x 20) + (0 x 21) + (1 x 22) + (1 x 23) + (0 x 24) + (0 x 25) + (0 x 26) + (0 x 27 

                    => (+13)10

Representation Table

No comments:

Post a Comment

Digital Electronics - Binary Number Representation

  Binary Number Representation There are 2 different kind of  binary numbers representation. Unsigned Binary Unsigned number contains only m...