Binary arithmetic

8,542 views

Published on

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,542
On SlideShare
0
From Embeds
0
Number of Embeds
225
Actions
Shares
0
Downloads
381
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Binary arithmetic

  1. 1. BINARY ARITHMETIC<br />Binary arithmetic is essential in all digital computers and in many other types of digital systems.<br />
  2. 2. Binary Addition<br />The four basic rules for adding binary digits are as follows:<br /> 0 + 0 = 0 Sum of 0 with a carry of 0<br /> 0 + 1 = 1 Sum of 1 with a carry of 0<br />1 + 0 = 1 Sum of 1 with a carry of 0<br />1 + 1 = 10 Sum of 0 with a carry of 1<br />
  3. 3. Examples:<br />Add the following binary numbers<br />11 + 11<br />100 + 10<br />111 + 11<br />110 + 100<br />
  4. 4. Binary subtraction<br />The four basic rules for subtracting binary digits are as follows:<br /> 0 - 0 = 0 <br />1 - 1 = 0<br /> 1 - 0 = 1 <br /> 10 - 1 = 10 – 1 with a borrow of 1<br />
  5. 5. Examples<br />Perform the following binary subtractions:<br />11 – 01<br />11 – 10<br />110100-11111<br />
  6. 6. Binary Multiplication<br />The four basic rules for multiplying binary digits are as follows:<br /> 0 x0 = 0 <br />0 x 1 = 0<br /> 1 x 0 = 0<br /> 1 x 1 = 1<br />
  7. 7. Examples<br />Perform the following binary multiplications:<br />11 x 11<br />101 x 111<br />1001 x 1011<br />
  8. 8. 1’s and 2’s complements of binary numbers<br /> The 1’s complement and the 2’s complement of a binary number are important because they permit the representation of negative numbers. The method of 2’s complement arithmetic is commonly used in computers to handle negative numbers.<br />
  9. 9. Obtaining the 1’s complement of a binary number<br /> The 1’s complement of a binary number is found by simply changing all 1s to 0s and all 0s to 1s.<br />Example:<br />0 1 1 1 0 0 1 0 Binary Number<br /> 1 0 0 0 1 1 0 1 1’s Complement <br />
  10. 10. Obtaining the 2’s complement of a binary number<br />The 2’s complement of a binary number is found by adding 1 to LSB of the 1’s complement.<br /> 2’s complement = (1’s complement) + 1<br />01110010 Binary Number<br /> 10001101 1’s Complement<br />+ 1 add 1<br /> 10001110 2’s Complement<br />
  11. 11. Signed numbers<br />Digital systems, such as the computer must be able to handle both positive and negative numbers. A signed binary number consists of both sign and magnitude information. The sign indicates whether a number is positive or negative and the magnitude is the value of a number. There are three ways in which signed numbers can be represented in binary form: sign-magnitude, 1’s complement, and 2’s complement. <br />
  12. 12. The sign bit<br />The left most bit in signed binary number is the sign bit, which tell you whether the number is positive or negative. A 0 is for positive, and 1 is for negative<br />Sign - magnitude system<br /><ul><li>When a signed binary number is represented in sign-magnitude, the left most bit is the sign bit and the remaining bits are the magnitude bits.</li></li></ul><li>Example<br /> Express the following decimal numbers as an 8-bit number in sign magnitude, 1’s complement and 2’s complement:<br />-39<br />-25<br />-78<br />-55<br />
  13. 13. Arithmetic operations with signed numbers<br />Addition<br /> The two numbers in addition are the addend and the augend. The result is the sum. There are four cases that occur when two signed binary numbers are added.<br />Both numbers are positive <br />Positive number with magnitude larger than negative numbers<br />Negative number with magnitude larger than positive numbers<br />Both numbers are negative<br />
  14. 14. Examples:<br /> Both numbers are positive <br /> 7 + 4 <br /> Positive number with magnitude larger than negative numbers<br /> 15 + -6<br /> Negative number with magnitude larger than positive numbers<br /> 16 + - 24<br /> Both numbers are negative<br /> -5 + -9<br />
  15. 15. Perform each of the following subtractions of the signed numbers:<br /> 1. 8 – 3<br />2. 12 – (-9)<br />3. -25 – (+19)<br />4. -120 – (-30)<br />
  16. 16. division<br />When two numbers are divided, both numbers must be in true (uncomplemented) form. The basic steps in a division process are as follows:<br />Step 1. Determine if the signs of the dividend and divisor are the same or different. This determines what the sign of the quotient will be. Initialize the quotient to zero.<br />Step 2. Subtract the divisor from the dividend using 2’s complement addition to get the first partial remainder and add 1 to the quotient. If the partial remainder is positive go to step 3. If the partial remainder is zero or negative, the division is complete.<br />Step 3. Subtract the divisor from the partial remainder and add 1 to the quotient. If the result is positive, repeat for the next remainder. If the result is zero or negative, the division is complete.<br /><ul><li>Continue to subtract the divisor from the dividend and the partial remainder until there is a zero or negative result.</li></ul>Example: Divide 01100100 by 00011001.<br />

×