1k likes | 2.24k Views
Signed Binary Number representation. Introduction. Binary numbers are represented with a separate sign bit along with the magnitude . For example, in an 8-bit binary number, the MSB is the sign bit and the remaining 7 bits correspond to magnitude. Magnitude.
E N D
Introduction • Binary numbers are represented with a separate sign bit along with the magnitude. • For example, in an 8-bit binary number, the MSB is the sign bitand the remaining 7 bits correspond to magnitude.
Magnitude • The magnitude part contains true binary equivalent of the number for positive numbers, while 2’s complement form of the number for the negative numbers
Example + 13 , 0 , - 46 are represented as follows Sign Magnitude 0 000 1101 +3 0 000 0000 0 1 010 1110 -46
Explanation • It is important to note that the number zero is assigned with the sign bit ‘0’ . • Therefore, the range of numbers that can be represented using 8-bit binary number is -128 to +127. • In general, the range of numbers that can be represented by n-bit number is (-2n-1) to (+2n-1-1)
Cases of Addition • When both the numbers are positive When augend is a positive and addend is a negative number When augend is a negative and addend is a positive number When both the numbers are negative
Case 1 Two positive numbers Consider the addition of +29 and +19 +29 0 0 0 1 1 1 0 (augend) 1 (addend) 0 0 0 1 0 0 1 1 +19 (Sum=48) 0 0 1 1 0 0 0 0 Sign bit
Explanation • The sign bits of both augend and addend are zero and the sign bit of the sum=0. • It indicating that when the sum is positive they have the same number of bits.
Case 2 Positive augend Number and Negative addend Number Consider the addition of +39 and -22 Complement -22 +22 [ 000 10110 ] Convert to -22 [ 111 01010] +39 0 0 1 0 0 1 1 (augend) 1 (addend) 1 1 1 0 1 0 1 0 -22 (Sum=17) 1 0 0 0 1 0 0 0 1 Carry Sign bit The carry is omitted. Then result is 0 0 0 1 0 0 0 1
Explanation • The sign bit of addend is 1. • A carry is generated in the last position of addition. • This carry is always omitted. • So the final Sum is 0 0 01 0 0 0 1
Case 3 Positive addend Number and Negative augend Number Consider the addition of -47and +29 Complement -47 +47 [ 0 01 01110] Convert to -47 [ 110 10001] -47 1 1 0 1 0 0 0 (augend) 1 (addend) 0 0 0 1 1 1 0 1 +29 (Sum=-18) 1 1 1 0 1 1 1 0 Sign bit
Explanation • The result has a sign bit of 1, indicating a negative number. • It is in the 2’s complement form. • The last seven bits 1101110 actually represent the 2’s complement of the sum.
Explanation Cont., • The true magnitude of the sum can be found by taking the 2’s complement of 1101110, the result is 10010 (+18). • Thus 11101110 represents -18
Case 4 Two Negative Numbers Consider the addition of -32 and -44 -32 1 1 1 0 0 0 0 (augend) 0 (addend) 1 1 0 1 0 1 0 0 -44 (Sum=-76) 1 0 1 1 0 1 0 0 1 Carry Sign bit The carry is discarded. Then result is 1 0 1 1 0 1 0 0
Explanation • The true magnitude of the sum is the complement of 0110100 , i.e., 1 0001100 (-76). • Thus, the 2’s complement addition works in every case. • This assumes that the decimal sum is within -128 to +127 range. Otherwise we get an overflow.
Introduction • As in the case of addition, subtraction can also be carried out in four possible cases. • Subtraction by the 2’s complement system involves addition.
Case 1 Both the Numbers are positive Consider the subtraction of +19 and +28 Complement +19 -19 [0001 0010] Convert to +19[ 1110 1101] Add the +28 and -19 as +28 0 0 0 1 1 1 0 0 1 1 1 0 1 1 0 1 +19 (Sum=9) 1 0 0 0 0 1 0 0 1 Carry
Case 2 Positive number and smaller Negative Number Consider the subtraction of +39 and -21 Complement -21 +21[1110 1011] Convert to -21[0001 0101] Add the +39 and +21 as +39 0 0 1 0 0 1 1 1 0 0 0 1 0 1 0 1 +21 (Sum=60) 0 0 1 1 1 1 0 0
Case 3 Positive Number and Larger Negative Number Consider the subtraction of +19 and -43 Complement -43 +43[1101 0100] Convert to -43[0010 1011] Add the +19 and +43 as +19 0 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 +43 (Sum=62) 0 0 1 1 1 1 1 1
Case 4 Both the Numbers are Negative Consider the subtraction of +33 and -57 Complement -57 +57[0011 1000] Convert to -57[1100 0111] Complement +33 -33[1101 1111] Convert to +33[0010 0001] Add the +33 and -57 as -57 1 1 0 0 0 1 1 1 0 0 1 0 0 0 0 1 +33 (Result=-24) 1 1 1 0 1 0 0 0
TheEnd ….... Thank You ……