Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1

2 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.

3 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

4 Example + 13, 0, - 46 are represented as follows Sign Magnitude +3 0 0 000 1101 0 0 0 000 0000 -46 1 1 010 1110

5 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 (-2 n-1 ) to (+2 n-1 -1)

6 Addition in the 2’s complement system

7 Cases of Addition 1.When both the numbers are positive 2.When augend is a positive and addend is a negative number 3.When augend is a negative and addend is a positive number 4.When both the numbers are negative

8 Case 1 Two positive numbers Consider the addition of +29 and +19 +29 1 0111000 (augend) +19 11001000 (addend) 00001100 (Sum=48) Sign bit

9 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.

10 Case 2 Positive augend Number and Negative addend Number Consider the addition of +39 and -22 -22+22 [ 000 10110 ]Convert to-22 [ 111 01010] Complement +39 1 1100100 (augend) -22 01010111 (addend) 100010001 (Sum=17) Sign bit Carry The carry is omitted. Then result is 0 0 0 1 0 0 0 1

11 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

12 Case 3 Positive addend Number and Negative augend Number Consider the addition of -47and +29 -47+47 [ 0 01 01110]Convert to-47 [ 110 10001] Complement -47 1 0001011 (augend) +29 10111000 (addend) 01110111 (Sum=-18) Sign bit

13 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.

14 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

15 Case 4 Two Negative Numbers Consider the addition of -32 and -44 -32 0 0000111 (augend) -44 00101011 (addend) 00101101 (Sum=-76) Sign bit 1 Carry The carry is discarded. Then result is 1 0 1 1 0 1 0 0

16 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.

17 Subtraction in the 2’s complement system

18 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.

19 Case 1 Both the Numbers are positive Consider the subtraction of +19 and +28 +19-19 [0001 0010]Convert to+19[ 1110 1101] Complement Add the +28 and -19 as +28 0 0111000 +19 10110111 1001000 01 (Sum=9) Carry

20 Case 2 Positive number and smaller Negative Number Consider the subtraction of +39 and - 21 -21+21[1110 1011]Convert to-21[0001 0101] Complement Add the +39 and +21 as +39 1 1100100 +21 10101000 0011110 0 (Sum=60)

21 Case 3 Positive Number and Larger Negative Number Consider the subtraction of +19 and - 43 -43+43[1101 0100]Convert to-43[0010 1011] Complement Add the +19 and +43 as +19 1 1001000 +43 11010100 1111110 0 (Sum=62)

22 Case 4 Both the Numbers are Negative Consider the subtraction of +33 and - 57 -57+57[0011 1000]Convert to-57[1100 0111] Complement +33-33[1101 1111]Convert to+33[0010 0001] Complement Add the +33 and -57 as -57 1 1100011 +33 10000100 0001011 1 (Result=-24)

23 ….... Thank You ……


Download ppt "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."

Similar presentations


Ads by Google