Presentation is loading. Please wait.

Presentation is loading. Please wait.

Binary Arithmetic Adding Binary numbers Overflow conditions

Similar presentations


Presentation on theme: "Binary Arithmetic Adding Binary numbers Overflow conditions"— Presentation transcript:

1 Binary Arithmetic Adding Binary numbers Overflow conditions How does it all work? AND, OR and NOT

2 Decimal Addition You are probably already familiar with adding decimal numbers 7 +2 9 5 +1 6 2 +3 5 You also know that when the addition of two numbers exceeds the base, a value is “carried” over to the next column 1 Carry the “1” 7 + 5 1 2

3 Binary Addition Adding binary numbers employs the same procedures as adding decimal numbers: 00 +00 01 +00 00 +01 01 As with decimal addition, when the addition of two numbers exceeds the base value, the value is “carried” over to the next column 1 Carry the “1” 01 +01 10

4 11 +11 ??? Binary Addition Examples 01001100 01101010 10110110
What happens when we have the following case? 1 Carry the “1” 11 +11 ???

5 More Binary Addition Examples
What happens when we get the following case? (note: assume that we are limited to 8 bits) ????????

6 Overflow In the following case, we have a condition called “overflow”. The result may be somewhat unexpected 1 Carry the “1” When adding two numbers, it is possible that the result will not fit within the space we have provided. The addition completes, but part of the value is lost. Luckily, overflow is often considered to be an error condition, so the program “knows” that this has happened and can take appropriate action.

7 How does it all work? In the first week of lectures, we discussed vacuum tubes, relays, and transistors As we went through the discussion, I asked, “How could you add two numbers using switches?” I didn’t expect an answer, but I did show how switches could be set up to implement the AND function and the OR function.

8 AND, OR and NOT You may recall the “truth” tables for the AND and OR functions: A A A 0 1 0 1 0 1 1 0 B B AND OR NOT (~) The AND, OR and NOT functions are the basic functions for “Boolean” Algebra

9 Binary Arithmetic/AND and OR
All binary arithmetic can be represented using boolean algebra Each 1-bit adder has 3 inputs: A, B and CarryIn Each 1-bit adder has 2 output: C and CarryOut CIN A B C COUT

10 Boolean Equations for Addition
CIN A B C COUT C = (~A and B and ~CIN) or (A and ~B and ~CIN) or (~A and ~B and CIN) or (A and B and CIN) COUT= (A and B) or (A and CIN) or (B and CIN)


Download ppt "Binary Arithmetic Adding Binary numbers Overflow conditions"

Similar presentations


Ads by Google