You are on page 1of 11

 In electronics (digital) all the operations are done using two levels of voltage: high

and low. Each level of voltage is assigned to a value/symbol: HIGH for 1 and
LOW for 0. For a microcontroller which is supplied with +5V the 1 (high) will be
represented by +5 V and the 0 (low) by 0 V.
 Roughly we can say that the binary system is used because it can be translated in
electronic signal.
 All the decimal numbers we can think of can be represented into binary symbols.
We do this by using a sum between terms of the power of 2 multiplied with 0 or
1.
2k 27 26 25 24 23 22 21 20

N … 128 64 32 16 8 4 2 1

As an example we’ll use the number 149 (decimal representation) and transform
it into binary representation.

27 26 25 24 23 22 21 20
1 0 0 1 0 1 0 1
7 6 5 4
1⋅2 0⋅2 0⋅2 1⋅2 0⋅23 1⋅2 2
0⋅21 1⋅20
128 + 0 + 0 + 16 + 0 + 4 + 0 + 1

= 149 10

13
Binary Arithmetic
1. Addition operation

0+0=0
0+1=1
1+0=1
1 + 1 = 0; and carry 1 to the next column.

Example 1: (00111+10101)2

Example 2: (1011.01 + 101.101)2

1011.010 +
0101.101

(10000.111)2

2. Subtraction operation

0-0=0
0 - 1 = 1; and barrow 1 from the next column.
1-0=1
1-1=0

Example 2: (1000.01 – 11.001)2


1000.010 –
0011.001

(101.001)2

14
3. Multiplication operation

0×0=0
0×1=0
1×0=0
1×1=1

Example 1: (0011010 × 001100)2

0011010 ×
001100
0000000
00000000 +
001101000
0011010000
(0100111000)2 (26 ×12)10 = (312)10

Example 2: (11.01 × 1.01)2

1101 ×
101
1101 +
00000
110100
(100.0001)2 (3.25 × 1.25)10 = (4.0625)10

4. Division operation

0÷ 0 = undefined
1÷ 0 = undefined
0÷ 1 = 0
1÷ 1 = 1

15
Example 1: (101101÷ 101)2
001001
101 101101 -
101
001 -
0
10 -
00
101 -
101
000
 So, (101101÷ 101)2= (1001)2 ; In decimal : 45 ÷ 5 = 9.

Example 2: (1101.01 ÷ 10)2

 So, (1101.01 ÷ 10)2= (110.101)2

16
R – Base Arithmetic
Example: Evaluate the following:

1. (42.51 + 15.3)8 & (42.51 – 15.3)8

42.51 42.51
+ –
15.30 15.30

(60.01)8 (25.21)8

2. (B3 + 4D)16 & (B3 – 4D)16

B3 B3
+ –
4D 4D

(100)16 (66)16

Homework

Perform the following operations


1. (50.27 )9 ÷ (15.28)9
2. (44.56)7 + (12.5)6
3. (B3)13 – (6.55)13
4. (33.24 )5 × (14.21)5

17
In digital systems, the complements are used to simplify the subtraction operation.
There are two types of complements for r – base system:
• r 's complement.
• (r – 1)'s complement.
In binary system, there are 2's complement and 1's complement which represent
the negative form of binary number.

1. The first complement (1's) are changed zeros to ones and ones to zeros.

Example 1:

1's
Example 2: (01001.1101)2 (10110.0010)2

2. The second complement (2's) can be either leaving least significant zeros and
ones’ digit unchanged then replacing 1's to 0's and 0's to 1's; or by forming 1's
complement and adding {1} for the least significant bit.

Example:
2's
(110101)2 ( )2's
1's
(110101)2 (001010) 1's + 1= (001011)2's
18
Subtraction using Complements
In digital computer, if the subtraction implemented, we use the complements and
addition as shown:
1. Convert the second number using 1's or 2's complement.
2. Replace the subtraction operation to addition operation.
Example 1: Perform the following operation using 2's complement:

(1010100)2 – (1000100)2

1's
Step 1 (1000100)2 (0111011)1's +1 = (0111100)2's

Step 2

1010100
+
0111100

1 0010000 (0010000)2
Ignored

Example 2: Perform the following operation using 2's complement:


(1010011.01)2 – (0101100.10)2

1's
(0101100.10)2 (1010011.01)1's +1 =(1010011.10)2's
1010011.01
+
1010011.10
1 0100110.11 (0100110.11)2
Ignored

19
Example 3: Perform the following operation using 1's complement.
(1010111)2 – (0110110)2

1's
(0110110)2 (1001001)1's

1010111
+
1001001
1 0100000
1 +
(100001)2

Example 4: Find the 12's complement and 13's complement to the number
[B65.5C]13.

CCC.CC

B65.5C

(167.70)12's + 1 = (167.71)13's

20
Digital systems are said to be constructed by using logic gates. These gates are the
AND, OR, NOT, NAND, NOR, EXOR and EXNOR gates. The basic operations are
described below with the aid of truth tables.

1. AND gate

F=AB

The AND gate is an electronic circuit that gives a high output (1) only if all its
inputs are high. A dot (.) is used to show the AND operation i.e. A.B. Keep in
mind that this dot is sometimes omitted i.e. AB

2. OR gate

F=A+B

The OR gate is an electronic circuit that gives a high output (1) if one or more of
its inputs are high. A plus (+) is used to show the OR operation.

3. NOT gate

F=A

21
The NOT gate is an electronic circuit that produces an inverted version of the input
at its output. It is also known as an inverter. If the input variable is A, the inverted
output is known as NOT A. This is also shown as A', or A with a bar over the top,
as shown at the outputs.

4. NAND gate

F=AB

This is a NOT-AND gate which is equal to an AND gate followed by a NOT


gate. The outputs of all NAND gates are high if any of the inputs are low. The
symbol is an AND gate with a small circle on the output. The small circle represents
inversion.

5. NOR gate

F=A+B

This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The
outputs of all NOR gates are low if any of the inputs are high. The symbol is an OR
gate with a small circle on the output. The small circle represents inversion.

22
6. EXOR gate (X-OR)

F=A  B

=AB+AB

The 'Exclusive-OR' gate is a circuit which will give a high output if either, but not
both, of its two inputs are high. An encircled plus sign ( ) is used to show the E-
OR operation.

7. EXNOR gate (X-NOR)

F=A  B

=AB+AB

The 'Exclusive-NOR' gate circuit does the opposite to the EOR gate. It will give a
low output if either, but not both, of its two inputs are high. The symbol is an EX-
OR gate with a small circle on the output. The small circle represents inversion.

Note:

The NAND and NOR gates are called universal functions since with
either one the AND, OR functions and NOT can be generated.

23

You might also like