Binary Addition & Binary Shifts

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Binary Addition

Rules
Rule 1: 0 + 0 = 0
Rule 2: 1 + 0 = 1
Rule 3: 1 + 1 = 10 (10 is the binary value for 2), where 1 is carried away
Rule 4: 1 + 1 + 1 = 11 (11 is the binary value for 3), where 1 is carried away
Example: Add 10010100 and 00011110

Overflow error
A type of error that occurs when a number larger than a register can store is generated.
Example: Add 10010100 and 10011110

Logical Binary shifts


Binary values can be shifted to the left or to the right.
Consider this binary value:

If a logical binary shift to the left is performed, the result will be:

The resulting empty sections are filled with a 0. Final result will be:
Negative Binary Numbers
So far, we have been using only positive binary number. But numbers can be negative, for
example -150.
How are negative numbers represented as binary?
Binary has only two values that can be used, a 0 and a 1. So, we cannot be a minus symbol
(-) in front of the number as it does not exist in binary.
Therefore, the method two’s complement is used to represent negative binary numbers.

Two’s complement
The method is very simple.
First, we invert all the values in binary number (change the 1s to 0s and 0s to 1s) which is
also known as the one’s complement.
Then we add 1 to the result.
Example: how is the denary value -35 represented in binary?
1. Convert 35 to binary number
Result:

2. Invert each of the value in the binary number (change the 1s to 0s and 0s to 1s)  one’s
complement
Result:

3. Add 1 to the obtained binary value.


11011100
+ 1
_______________
11011101

Result:

Note:
1. one’s complement is just the inversion of the binary values, that
is changing the 1s to 0s and 0s to 1s.
2. two’s complement is the inversion of the binary values
(changing the 1s to 0s and 0s to 1s) then adding 1 to the obtained
inverted value.

You might also like