Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Digital Electronics

EE008-3-2-DE / VE2

Number System
TOPIC & STRUCTURE OF THE
LESSON

• Number Bases
• Gray Code
• Representation of negative numbers
• Addition and Subtraction of Base 2, 16
and 8

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 2


LEARNING OUTCOMES

• At the end of this topic, YOU should be


able to:
– Interpret the operation of digital circuits.
(C3, PLO2)

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 3


KEY TERMS YOU MUST BE ABLE
TO USE

• If you have mastered this topic, you should be able


to use the following terms correctly in your
assessments: -
– Binary
– Hexadecimal
– Decimal
– Octal
– Signed
– Gray code

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 4


NUMBER BASES

• Decimal (Base 10) 0~9

• Binary (Base 2) 0~1

• Octal (Base 8) 0~7

• Hexadecimal (Base 16) 0~F

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 5


NUMBER BASES

Fig. 1.1: Number bases


EE008-3-2-Digital Electronics Ch1-Number Systems Slide 6
BINARY NUMBER

• The binary number system has two digits:


– 0 represents the no voltage or an off state
– 1 represents the presence of voltage or an on state
• The binary numbering system has a base of 2 with
each position weighted by a factor of 2:

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 7


BINARY TO DECIMAL CONVERSION

Example 1.1
Convert the binary whole number 1101101 to decimal

Weight 26 25 24 23 22 21 20

Binary Number 1 1 0 1 1 0 1

• Therefore 1101101 = 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23+ 1 x 22 +


1 x 20
= 64 +32 +8 +4 +1
= 109
EE008-3-2-Digital Electronics Ch1-Number Systems Slide 8
Binary Fractions-to-Decimal Conversion

Example 1.2
Convert the fractional binary number 110.1011 to decimal

• Therefore 110.1011 = 1 x 22 + 1 x 21 + 1 x 2-1+ 1 x 2-3 + 1 x 2-4


= 4 + 2 +0.5 +0.125+0.0625
= 6.6875

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 9


BINARY TO DECIMAL CONVERSION

Exercise 1.1
• 100112
• 11100112
• 101010.1112
• 1110010.1112
• 0101112
• 00011100.10112
• 1000001.0112
• 010101.12

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 10


BINARY TO DECIMAL CONVERSION

Exercise 1.1
• 100112
• 11100112
• 101010.1112
• 1110010.1112
• 0101112
• 00011100.10112
• 1000001.0112
• 010101.12

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 11


DECIMAL TO BINARY CONVERSION

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 12


DECIMAL TO BINARY CONVERSION

• Decimal fractions can be converted to binary by


repeated multiplication by 2
Example 1.3
Convert the decimal fraction 0.3125 to binary

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 13


Decimal Fractions-to-Binary Conversion

• Repeated Multiplication-by-2 method


Example 1.4
Convert the decimal fraction 0.1 to binary
• Solution:
– Since 0.110 = 0.000110011001100112
– The repeating pattern is more obvious if
we highlight it in color as below:
0.1 (decimal) = .00011001100110011 . . . (base 2)
– Therefore 0.110 = 0.00 011

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 14


DECIMAL TO BINARY CONVERSION

• INTEGER DIGIT:
– Repeated division by the radix & record the remainder
• FRACTIONAL DECIMAL:
– Multiply the number by the radix until the answer is in integer
Example 1.4
Convert the decimal fraction 25.3125 to binary

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 15


DECIMAL TO BINARY CONVERSION

2 5 = 12 + 1
2
12 = 6 + 0
2
6 = 3 + 0
2
3 = 1 + 1
2
1 = 0 + 1
2 MSB LSB
2510 = 1 1 0 0 1 2
EE008-3-2-Digital Electronics Ch1-Number Systems Slide 16
DECIMAL TO BINARY CONVERSION

Carry .0 1 0 1
0.3125 x 2 = 0.625 0

0.625 x 2 = 1.25 1

0.25 x 2 = 0.50 0

0.5 x 2 = 1.00 1

The Answer: 1 1 0 0 1.0 1 0 1


EE008-3-2-Digital Electronics Ch1-Number Systems Slide 17
DECIMAL TO BINARY CONVERSION

Exercise 1.2
1. 1010
2. 101.5937510
3. 49. 32510
4. 21.510
5. 21610
6. 14510
7. 98.07510
8. 12710

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 18


DECIMAL TO BINARY CONVERSION

Exercise 1.2
1. 1010
2. 101.5937510
3. 49. 32510
4. 21.510
5. 21610
6. 14510
7. 98.07510
8. 12710

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 19


HEXADECIMAL NUMBERS
BASE 16
• The Hexadecimal (HEX) number system has a base of
sixteen as shown in the Table.
• It is composed of 16 numeric and alphabetic characters
• Hexadecimal digit represent a 4-bit binary number.
DECIMAL BINARY HEX
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 20


BINARY-TO-HEX CONVERSION

Example 1.5
Convert the following binary numbers to hex:
a) 1100101001010111
b) 111111000101101001

Solution
• Convert, each 4-bit group to the equivalent hex, starting
at the most right bit
(a) 11001010 01010111 (b) 0011111100 0101101001 = 3F169
C A 5 7 = CA57 3 F 1 6 9

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 21


HEX-TO-BINARY CONVERSION

Example 1.6
Determine the binary number for the following hex numbers
a) 10A4
b) CF8E
c) 23.A3

Solution
• Reverse the process. Convert each hex digit to a 4 digit
binary number

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 22


HEX TO BIN & BIN TO HEX
CONVERSION

Exercise 1.3
Convert the following binary numbers to their hexadecimal
equivalent (vice versa).
a) 10000.12
b) 1F.C16

Solution:
a) 10.816
b) 00011111.11002

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 23


HEX-TO-DECIMAL CONVERSION

• Multiply each hexadecimal digit by its weight (weight is 16


power of digit location)
• Sum all the multipliers.

Example 1.7
Determine the decimal number for the following hex numbers
a) BE = B 16 + E 16 = 1116 + 14 1 = 190
1 0

b) 54 = 5 161 + 4 160 = 5 16 + 14 1 = 84

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 24


DECIMAL-TO-HEX CONVERSION

• Repeated division of a decimal by 16 will produce the


equivalent hexadecimal number

Example 1.8
Determine the hex number for the following decimal numbers:
a) 84 = 5416

b) 190 = BE16

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 25


OCTAL NUMBERS
BASE 8
• The Octal number system is composed of 8 digits, which
are; 0,1,2,3,4,5,6,7 as shown in table below

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 26


BINARY-TO-OCT CONVERSION

Example 1.9
Convert the following binary numbers to octal:
a) 1100101001010110
b) 1111.0001011011
Solution
• Convert, each 3-bit group to the equivalent octal,
starting at the most right bit
a) 1451268

b) 17.05548

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 27


OCT-TO-BINARY CONVERSION

Example 1.10
Determine the binary number for the following octal
numbers
a) 124
b) 276
Solution
• Reverse the process. Convert each octal digit to a 3digit
binary number

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 28


OCT TO BIN & BIN TO OCT
CONVERSION

Exercise 1.4
Convert the following binary numbers to their octal
equivalent (vice versa).
a) 1001.11112
b) 47.38
c) 1010011.110112

Solution:
a) 11.748
b) 100111.0112
c) 123.668
EE008-3-2-Digital Electronics Ch1-Number Systems Slide 29
OCTAL-TO-DECIMAL CONVERSION

• Multiply each octal digit by its weight. (weight is 8 power


of digit location)
• Sum all the multipliers.

Example 1.11
Determine the decimal number for the following octal numbers
a) 1248 = 1 82 + 2  81 + 4  80 = 64 + 16 + 4 = 8410

b) 2768 = 2  82 + 7  81 + 6  80 = 128 + 56 + 6 = 19010

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 30


DECIMAL-TO-OCTAL CONVERSION

• Repeated division of a decimal by 8 will produce the


equivalent octal number

Example 1.12
Determine the octal number for the following decimal numbers:
a) 84 = 1248

b) 276 = 4248

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 31


BINARY CODED DECIMAL

• Binary Coded Decimal (BCD) is a way to express each of the decimal


digits with a binary code
• Only ten code groups in a BCD system (0 to 9).

• IF the number contains two decimal digits, then it’s equivalent BCD
will be the respective eight binary of the given decimal number.
• Four for the first decimal digit and next four for the second decimal
digit.
• Forms the easy interface between man machine- e.g keypad inputs
and digital readouts

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 32


DECIMAL-TO-BCD CONVERSION

Example 1.13
Find the equivalent BCD for the following decimal numbers
a) 1210

Solution
a) Decimal to BCD
1210 = 00010010BCD

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 33


BCD-TO-DECIMAL CONVERSION

Example 1.14
Find the equivalent BCD for the following decimal numbers
a) 10000110BCD
b) 001101010001BCD

Solution

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 34


BCD CODING VS. STRAIGHT BINARY
CODING

• BCD coding is easier

13710 = 000100110111BCD

The BCD code is 0001 0011 0111 The straight binary code is 100010012
EE008-3-2-Digital Electronics Ch1-Number Systems Slide 35
BINARY CODED DECIMAL

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 36


GRAY CODE

• Unweighted (no specific weight assigned to the bit position)


• Can’t be used in arithmetic circuits
• Only 1 bit changes from one code to the next sequence
• To reduce errors

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 37


BINARY TO GRAY CONVERSION

• The MSB in the Gray code is same as the corresponding MSB in the
binary number
• From left to right, add each adjacent pair of binary code to get the
next Gray code bit.
• Discard Carries
• Example , the conversion of the binary number 10110 to gray code

• Gray Code 11101


EE008-3-2-Digital Electronics Ch1-Number Systems Slide 38
GRAY TO BINARY CONVERSION

• The MSB in the Binary number is same as the corresponding MSB in the
Gray code
• From left to right, add each binary code bit generated to the gray
code bit in the next adjacent position
• Discard Carries
• Example , the conversion of the gray code 11011 to binary number

• Binary 10010
EE008-3-2-Digital Electronics Ch1-Number Systems Slide 39
GRAY TO BINARY CONVERSION

Exercise 1.5

Solution

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 40


REPRESENTATION OF
NEGATIVE NUMBERS
• Computer must be handle both positive and negative
numbers.
• 3 types of representation:
– Sign and magnitude (least used)
– 1’s complement
– 2’s complement (most important)

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 41


SIGN NUMBERS
SIGN -MAGNITUDE
• The representation of a signed binary number is
commonly referred to as the sign-magnitude notation
• The left-most bit is the sign bit and the remaining are the
magnitude bit.
• The magnitude bits are true binary for positive and
negative numbers.
• The left most bit in a binary number is the sign bit, which
tells you whether the number is positive or negative.
– A “0”sign bit indicates a positive number.
– A “1”sign bit indicates a negative number.

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 42


SIGN NUMBERS
SIGN -MAGNITUDE
Example 1.6
The decimal number +23 is expressed as an 8-bit signed
binary number using the sign-magnitude

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 43


SIGN NUMBERS
1’s complement
• Positive number in 1’s complement same as the positive sign-
magnitude numbers.
• E.g: +23 is 00010111
• The negative number is the 1’s complement of the
corresponding positive number

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 44


SIGN NUMBERS
2’s complement
• Positive number in 2’s complement same as the positive sign-
magnitude and 1’s complement forms.
• E.g: +23 is 00010111
• The negative number is the 1’s complement of the
corresponding positive number

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 45


SIGN NUMBERS

Example 1.7
Express the decimal +19 and -19 as an 8-bit number in the:
a) sign magnitude
b) 1’s complement
c) 2’s complement

Solution

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 46


DECIMAL VALUE OF SIGNED
NUMBERS

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 47


DECIMAL VALUE OF SIGNED
NUMBERS
Example 1.8
Determine the decimal values of the signed binary numbers:

Solution

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 48


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• Binary Addition

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 49


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• Binary Subtraction

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 50


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• Binary Multiplication

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 51


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• Binary Division

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 52


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• Hexadecimal Addition

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 53


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• Hexadecimal Subtraction

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 54


ADDITION AND SUBTRACTION
(BINARY, DECIMAL , HEXADECIMAL,
OCTAL)
• BCD ADDITION

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 55


QUICK REVIEW QUESTIONS

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 56


SUMMARY OF MAIN TEACHING
POINTS

• What was covered today:-


– Review decimal, binary, octal and hexadecimal
number system
– Convert from one base number to another base
number
– Signed binary number ( sign-magnitude, 1’s and
2’s complement)
– Carry out arithmetic operation using signed
numbers

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 57


QUESTION AND ANSWER
SESSION

Q&A

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 58


WHAT WE WILL COVER NEXT

• Logic Gates and Boolean Algebra

EE008-3-2-Digital Electronics Ch1-Number Systems Slide 59

You might also like