You are on page 1of 14

Binary Operations

 The term binary means consisting of two parts. In


mathematics, binary means it belongs to a number system
with base 2 and not base 10.
 A binary number is made up of only 0’s and 1’s
Examples: Binary and
Decimal and
There is no 2, 3, 4, 5, 6, 7, 8, 9,
A bit is a single binary digit
The number 11010 has 5 bits
 Examples:

1. transform the binary number

Solution:
1(64)+1(32)+1(16)+1(8)+1(4)+1(2)+1(1)
64+32+16+8+4+2+1=
2.

Solution: 1()+1()+1()+1()+1()+0()
32 + 16 +8 +4 +2 +0
=
3.

Solution: 32+16+8+0+2+1 =
Exercise

Convert the following binary numbers to their decimal equivalents:


Write the decimal number to binary
 Examples:
1. write the decimal 69 to binary
Division by 2 Quotient Remainder Place of Bits
2)69 34 1 1’s
2)34 17 0 2’s
2)17 8 1 4’s
2)8 4 0 8’s
2)4 2 0 16’s
2)2 1 0 32’s
2)1 0 1 64’s
0

By reading backward, (the first digit of the binary is the 64’s), we obtain:
=
2. Write the Decimal 63 to binary
Division by 2 Quotient Remainder Place of Bits
2)63 31 1 1’s
2)31 15 1 2’s
2)15 7 1 4’s
2)7 3 1 8’s
2)3 1 1 16’s
2)1 0 1 32’s
0

As always, we need to stop when the dividend becomes zero. By


reading backward, (the first digit of the binary is the 32’s), we
obtain:

=
Exercise:
1.
Operations of Binary Numbers

Binary numbers are computed using the different fundamental operations.

Addition
In adding binary numbers, we use the fact that the sum of the
numbers must be one and zero only. Thus, the sum of 0 and 0 is 0; the sum
of 1, and the sum 1 and 1 is 0.
Consider the examples:
1. If we add and , we have the following solution,
carry-> 1
1 0 0 1
1 1 1 0
1 0 1 1 1
 To check whether our answers are correct, we convert and to decimal numbers, as well as the
sum

= 1(8)+0(4)+0(2)+1(1)= 9
= 1(8)+1(4)+1(2)+1(0)= 14
We should expect that is 23.
=1(16)+0(8)+1(4)+1(2)+1(1)= 23
2.
3. The sum oftheand
Similarly, sumisof
shown
and below:
is:
Carry -> 1 1 1
1 0 1 1 0 1
1 0 0 1 1 0
1 0 1 0 0 1 1

Carry - 1 1 1 1 1 1
>
1 1 1 1 1 1
1 0 1 1 1 1
1 1 0 1 1 1 0

Can you verify whether our answers are


correct?
Subtraction:
 In subtracting binary numbers, we also use the fact that the
difference of the numbers must be one and zero only. Please note that
we are limited to subtracting bigger numbers by smaller numbers. Thus,
the difference of 0 and 0 is 0; the difference of 1 and 0 is 1; the
difference 0 and 1 is 1 (we need to borrow 1), and the difference of
1 and 1 is 0. Consider the examples below
1. If we subtract and we have the solution:

1 1 1 0 => 1 1 0 1
0
1 0 0 1 1 0 0 1
1 0 1
 We are checking whether the difference of 14 and 9 is 5
= 1(8) + 1(4) + 1(2) + 0(1) = 14
= 1(8) + 0(4) + 0(2) + 1(1) = 9
2. Suppose we will subtract and
1 1 1 1 0 1 1 1 0 10
1 0 1 0 1 1 0 1 0 1
1 0 0 1

We are checking whether the difference of 30 and 21 is 9

21
Exercise
Find the sum of the following binary numbers:
1. and
2. and

Find the difference of the following binary numbers:


1. and
2. and

You might also like