Contents
• Number system
• Decimal Number System
• Binary Number System
• Octal Number System
• Hexadecimal Number System
• Number Conversion
• Simple Binary Arithmetic
6/12/2020 Basic Electronics (BE 2101) Module – III 1
Decimal Numbers
Characteristics
1. Base or radix is 10.
2. Numbers 0 to 9.
3. Weights before decimal point
…105 104 103 102 101 100.
4. Weights after decimal point
102 101 100. 10-1 10-2 10-3 10-4 …
6/12/2020 Basic Electronics (BE 2101) Module – III 2
Binary Numbers
Characteristics
1. Base or radix is 2.
2. Numbers 0 and 1.
6/12/2020 Basic Electronics (BE 2101) Module – III 3
Binary Numbers Decimal Binary
Number Number
A binary counting sequence for numbers 0 0000
from zero to fifteen is shown. 1 0001
2 0010
Notice the pattern of zeros and ones in each 3 0011
4 0100
column.
5 0101
6 0110
Digital counters frequently have this same 7 0111
pattern of digits: 8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
6/12/2020 Basic Electronics (BE 2101) Module – III 4
Decimal to Binary Conversions
Convert the decimal number 25 to binary.
(25)10 = (11001)2
6/12/2020 Basic Electronics (BE 2101) Module – III 5
Decimal to Binary Conversions
Convert the decimal number 25 to binary.
The column weights double in each position to the
right. Write down column weights until the last
number is larger than the one you want to convert.
25 24 23 22 21 20.
32 16 8 4 2 1.
0 1 1 0 0 1.
6/12/2020 Basic Electronics (BE 2101) Module – III 6
Decimal to Binary Conversions
Convert the decimal number 0.16 to binary.
6/12/2020 Basic Electronics (BE 2101) Module – III 7
Decimal to Binary Conversions
Convert the decimal fraction 0.188 to binary by
repeatedly multiplying the fractional results by 2.
0.188 x 2 = 0.376 carry = 0 MSB
0.376 x 2 = 0.752 carry = 0
0.752 x 2 = 1.504 carry = 1
0.504 x 2 = 1.008 carry = 1
0.008 x 2 = 0.016 carry = 0
Answer = .00110 (for five significant digits)
6/12/2020 Basic Electronics (BE 2101) Module – III 8
Exercise
Convert the decimal number 12.75 to binary.
(12.75)10 = (1100.11)2
6/12/2020 Basic Electronics (BE 2101) Module – III 9
Binary to Decimal Conversions
Convert the binary number (110100)2 to decimal.
6/12/2020 Basic Electronics (BE 2101) Module – III 10
Binary to Decimal Conversions
Convert the binary number 100101.01 to decimal.
Start by writing the column weights; then add the
weights that correspond to each 1 in the number.
25 24 23 22 21 20. 2-1 2-2
32 16 8 4 2 1 . ½ ¼
1 0 0 1 0 1. 0 1
32 +4 +1 +¼ = 37¼
6/12/2020 Basic Electronics (BE 2101) Module – III 11
Decimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
6/12/2020 Basic Electronics (BE 2101) Module – III 12
Exercise
Convert (101100.1101)2 to decimal.
(101100.1101)2 = (44.8125)10
6/12/2020 Basic Electronics (BE 2101) Module – III 13
Binary Arithmetic
6/12/2020 Basic Electronics (BE 2101) Module – III 14
Binary Addition
The rules for binary addition are
0+0=0 Sum = 0, carry = 0
0+1=0 Sum = 1, carry = 0
1+0=0 Sum = 1, carry = 0
1 + 1 = 10 Sum = 0, carry = 1
6/12/2020 Basic Electronics (BE 2101) Module – III 15
Binary Addition
Add the binary numbers 00111 and 10101 and show
the equivalent decimal addition.
0 1 1 1
0 0 1 1 1 7
1 0 1 0 1 21
1 1 1 0 0 = 28
6/12/2020 Basic Electronics (BE 2101) Module – III 16
Binary Subtraction
The rules for binary subtraction are
0–0 =0
10 – 1 = 1, 0 – 1 with a borrow of 1
1–0 =1
1–1 =0
6/12/2020 Basic Electronics (BE 2101) Module – III 17
Binary Subtraction
Subtract the binary number 0110 from 1001.
1 1
1 0 0 1
0 1 1 0
0 0 1 1
6/12/2020 Basic Electronics (BE 2101) Module – III 18
1’s complement
The 1’s complement of a binary number is just the inverse
of the digits. To form the 1’s complement, change all 0’s to
1’s and all 1’s to 0’s.
For example, the 1’s complement of 11001010 is
00110101
6/12/2020 Basic Electronics (BE 2101) Module – III 19
2’s complement
The 2’s complement of a binary number is found by adding
1 to the LSB of the 1’s complement.
For example, the 1’s complement of 1 1 0 0 1 0 1 0 is
00110101
+1
To form the 2’s complement, add 1:
00110110
(2’s complement)
6/12/2020 Basic Electronics (BE 2101) Module – III 20
Signed Binary Numbers
There are several ways to represent signed binary numbers.
In all cases, the MSB in a signed number is the sign bit, that
tells you if the number is positive or negative.
If MSB is 0 then it is positive number.
If MSB is 1 then it is negative number.
For example, the positive number 58 is written using 8-bits
as 00111010
Sign bit
Magnitude bits
6/12/2020 Basic Electronics (BE 2101) Module – III 21
Signed Binary Numbers
Negative numbers are written as the 2’s complement of the
corresponding positive number.
The negative number -58 is written as:
-58 = 1 1 0 0 0 1 1 0 (2’s complement form)
Sign bit Magnitude bits
6/12/2020 Basic Electronics (BE 2101) Module – III 22
Arithmetic Operations with Signed Numbers
Rules for addition: Add the two signed numbers. Discard
any final carries. The result is in signed form.
Examples:
00011110 = +30 00001110 = +14 11111111 = -1
00001111 = +15 11101111 = -17 11111000 = -8
00101101 = +45 11111101 = -3 1 11110111 = -9
Discard carry
6/12/2020 Basic Electronics (BE 2101) Module – III 23
Arithmetic Operations with Signed Numbers
Rules for subtraction: 2’s complement the subtrahend and
add the numbers. Discard any final carries. The result is in
signed form.
Repeat the examples done previously, but subtract:
00011110 (+30) 00001110 (+14) 11111111 (-1)
- 00001111 –(+15) - 11101111 –(-17) - 11111000 –(-8)
2’s complement subtrahend and add:
00011110 = +30 00001110 = +14 11111111 = -1
11110001 = -15 00010001 = +17 00001000 = +8
1 00001111 = +15 00011111 = +31 1 00000111 = +7
Discard carry Discard carry
6/12/2020 Basic Electronics (BE 2101) Module – III 24
Octal Numbers
Characteristics
1. Base or radix is 8.
2. Numbers 0 to 7. i.e. 0, 1, 2, 3, 4, 5, 6, 7
3. Weights before decimal point
…85 84 83 82 81 80.
4. Weights after decimal point
82 81 80. 8-1 8-2 8-3 8-4 …
6/12/2020 Basic Electronics (BE 2101) Module – III 25
Representation of Octal Number
Each Octal number can be represented in binary using only 3
bits.
The equivalent binary number of Octal number are as given
below −
Octal Digit Value Binary Equivalent
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
6/12/2020 Basic Electronics (BE 2101) Module – III 26
Octal to Binary and vice versa
Example-1 − Octal to Binary
(27)8 = (010 111)2
(156)8 = (001 101 110)2
(25.35)8 = (010 101.011 101)2
Example-2 − Binary to Octal
(101110)2 = (101 110)2 = (56)8
(1001.1001)2 = (001 001.100 100)2 = (11.44)8
6/12/2020 Basic Electronics (BE 2101) Module – III 27
Octal to Decimal and vice versa
Example-1 − Octal to Decimal
(25)8 = 2x81+5x80=16+5=(21)10
(127)8 = 1x82+2x81+7x80=64+16+7=(87)10
(25.35)8 = 2x81+5x80+3x8-1+5x8-2=16+5+0.453125=(21.453125)10
Example-2 − Decimal to Octal
(21)10 =
6/12/2020 Basic Electronics (BE 2101) Module – III 28
Octal to Decimal and vice versa
The decimal value of any octal number can be determined using
sum of product of each digit with its positional value.
Example-1 − Octal Digit Value 23228
In polynomial form = ( 2×83 ) + ( 3×82 ) + ( 2×81 ) + ( 2×80 )
Add the results = ( 1024 ) + ( 192 ) + ( 16 ) + ( 2 )
Decimal number form equals: 123410
Example-2 − A decimal number 21 to represent in Octal
representation
6/12/2020 Basic Electronics (BE 2101) Module – III 29
Hexadecimal Number System
Characteristics
Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Letters represents numbers starting from 10. A = 10, B = 11, C
= 12, D = 13, E = 14, F = 15.
Base = 16
6/12/2020 Basic Electronics (BE 2101) Module – III 30
Hexadecimal Number System
6/12/2020 Basic Electronics (BE 2101) Module – III 31
Hexadecimal to Binary and vice versa
Example-1 − Hexadecimal to Binary
(27)16 = (0010 0111)2
(156)16 = (0001 0101 0110)2
(25.35)16 = (0010 0101.0011 0101)2
Example-2 − Binary to Hexadecimal
(101110)2 = (0010 1110)2 = (2E)16
(1001.1001)2 = (1001.1001)2 = (9.9)16
6/12/2020 Basic Electronics (BE 2101) Module – III 32
Hexadecimal to Decimal
Example Hexadecimal Number − 19FDE 16
Calculating Decimal Equivalent −
Step Hexadecimal Number Decimal Number
4 3 2
Step 1 19FDE16 ((1 × 16 ) + (9 × 16 ) + (F × 16 ) + (D ×
1 0
16 ) + (E × 16 ))10
4 3 2
Step 2 19FDE16 ((1 × 16 ) + (9 × 16 ) + (15 × 16 ) + (13
1 0
× 16 ) + (14 × 16 ))10
Step 3 19FDE16 (65536 + 36864 + 3840 + 208 + 14)10
Step 4 19FDE16 10646210
6/12/2020 Basic Electronics (BE 2101) Module – III 33
Binary Codes
In the coding, when numbers, letters or words are represented by a specific
group of symbols, it is said that the number, letter or word is being encoded.
The group of symbols is called as a code.
The digital data is represented, stored and transmitted as group of binary bits.
This group is also called as binary code.
The binary code is represented by the number as well as alphanumeric letter.
Binary codes can be classified into two types.
Weighted codes
Unweighted codes
If the code has positional weights, then it is said to be weighted code.
Otherwise, it is an unweighted code.
6/12/2020 Basic Electronics (BE 2101) Module – III 34
Binary Codes – 8 4 2 1 code
Decimal Digit 8421 Code
8 4 2 1 code
0 0000
The weights of this code are 8, 4, 2
and 1. 1 0001
2 0010
This code has all positive weights. 3 0011
So, it is a positively weighted
4 0100
code.
5 0101
This code is also called as natural 6 0110
BCD (Binary Coded Decimal)
7 0111
Code.
8 1000
9 1001
6/12/2020 Basic Electronics (BE 2101) Module – III 35
Binary Codes – 8 4 2 1 code
Example Decimal Digit 8421 Code
Let us find the BCD equivalent of the 0 0000
decimal number 786. This number has 3
decimal digits 7, 8 and 6. From the table, 1 0001
we can write the BCD 8421 codes of 7, 8 2 0010
and 6 are 0111, 1000 and 0110 3 0011
respectively.
4 0100
(786)10 = (011110000110)BCD 5 0101
6 0110
There are 12 bits in BCD representation,
7 0111
since each BCD code of decimal digit has 4
bits. 8 1000
9 1001
6/12/2020 Basic Electronics (BE 2101) Module – III 36
Binary Codes – Excess 3 code
Decimal Digit Excess 3 Code
Excess 3 code
0 0011
This code doesn’t have any weights. So, it 1 0100
is an un-weighted code. 2 0101
3 0110
We will get the Excess 3 code of a decimal
number by adding three 00110011 to the 4 0111
binary equivalent of that decimal number. 5 1000
Hence, it is called as Excess 3 code. 6 1001
7 1010
It is a self-complementing code.
8 1011
9 1100
6/12/2020 Basic Electronics (BE 2101) Module – III 37
Excess 3 code
Example Decimal Digit Excess 3 Code
0 0011
Let us find the Excess 3 equivalent of the 1 0100
decimal number 786.
2 0101
This number has 3 decimal digits 7, 8 and 3 0110
6. From the table, we can write the Excess 4 0111
3 codes of 7, 8 and 6 are 1010, 1011 and
5 1000
1001 respectively.
6 1001
Therefore, the Excess 3 equivalent of the 7 1010
decimal number 786 is 101010111001 8 1011
9 1100
6/12/2020 Basic Electronics (BE 2101) Module – III 38
Gray code
Decimal Number Binary Code Gray Code
The table shows the
0 0000 0000
4-bit Gray codes
corresponding to 1 0001 0001
each 4-bit binary 2 0010 0011
code. 3 0011 0010
4 0100 0110
This code doesn’t have 5 0101 0111
any weights. So, it is 6 0110 0101
an un-weighted code. 7 0111 0100
8 1000 1100
In the above table, the
9 1001 1101
successive Gray codes
10 1010 1111
are differed in one bit
position only. Hence, 11 1011 1110
this code is called 12 1100 1010
as unit distance code. 13 1101 1011
14 1110 1001
15 1111 1000
6/12/2020 Basic Electronics (BE 2101) Module – III 39
Logic Gate
6/12/2020 Basic Electronics (BE 2101) Module – III 40
Logic Gates
Logic gates are the basic building blocks of any digital
system.
It is an electronic circuit having one or more than one
input and only one output.
The relationship between the input and the output is
based on a certain logic.
Based on this, logic gates are named as AND gate, OR
gate, NOT gate etc.
6/12/2020 Basic Electronics (BE 2101) Module – III 41
AND Gate
AND Gate
It produces HIGH output only when all the inputs are
HIGH.
Logic Circuit
Truth Table
Inputs Output
A B Y
0 0 0
Logical Equation
0 1 0
Y=A.B 1 0 0
1 1 1
6/12/2020 Basic Electronics (BE 2101) Module – III 42
OR Gate
OR Gate
It produces HIGH output when one or more inputs are
HIGH.
Logic Circuit
Truth Table
Inputs Output
A B Y
0 0 0
Logical Equation
0 1 1
Y=A+B 1 0 1
1 1 1
6/12/2020 Basic Electronics (BE 2101) Module – III 43
NOT Gate
NOT Gate
It produces HIGH output when input is LOW. And when
the input is LOW, the output is HIGH.
Logic Circuit
Truth Table
Inputs Output
A Y
Logical Equation
0 1
Y= A 1 0
6/12/2020 Basic Electronics (BE 2101) Module – III 44
NAND Gate
NAND Gate
A NOT-AND operation is known as NAND operation. It
has n input (n >= 2) and one output.
Logic Circuit Truth Table
Logical Equation
Y = AB
6/12/2020 Basic Electronics (BE 2101) Module – III 45
NOR Gate
NOR Gate
A NOT-OR operation is known as NOR operation. It has n
input (n >= 2) and one output.
Logic Circuit Truth Table
Logical Equation
Y =A + B
6/12/2020 Basic Electronics (BE 2101) Module – III 46
XOR Gate
XOR Gate
XOR or Ex-OR gate is a special type of gate. It can be used in the
half adder, full adder and subtractor. The exclusive-OR gate is
abbreviated as EX-OR gate or sometime as X-OR gate. It has n input
(n >= 2) and one output. Truth Table
Logic Circuit
Logical Equation
Y = A B
6/12/2020 Basic Electronics (BE 2101) Module – III 47
END
6/12/2020 Basic Electronics (BE 2101) Module – III 48