Detail number system understanding, operations on the number system and coding shows here in this topic
Size: 529.17 KB
Language: en
Added: Oct 09, 2025
Slides: 31 pages
Slide Content
EKT 121/4 EKT 121/4
ELEKTRONIK DIGIT 1 ELEKTRONIK DIGIT 1
Kolej Kolej
Universiti Universiti
Kejuruteraan Kejuruteraan
Utara Utara
Malaysia Malaysia
Chapter 2 : Chapter 2 :
Number Systems, Operations Number Systems, Operations
and Codes and Codes
Number Systems & Codes Number Systems & Codes
„„
Introduction to number systems Introduction to number systems
„„
Decimal Decimal
„„
Binary Binary
„„
Octal Octal
„„
Hexadecimal Hexadecimal
„„
Number Conversion Number Conversion
„„
Simple Arithmetic Simple Arithmetic
„„
Binary Codes Binary Codes
Number Systems Number Systems
„„
Decimal Decimal
„„
Binary Binary
„„
Octal Octal
„„
Hexadecimal
¾¾
0 ~ 9 0 ~ 9
¾¾
0 ~ 1 0 ~ 1
¾¾
0 ~ 7 0 ~ 7
¾¾
0 ~ F
Hexadecimal
0 ~ F
Number Conversion Number Conversion
„„
Introduction to bit and byte Introduction to bit and byte
„„
Introduction to LSB (Least Significant Bit) Introduction to LSB (Least Significant Bit) & MSB (Most Significant Bit) & MSB (Most Significant Bit)
„„
Any Radix (base) to Decimal Conversion Any Radix (base) to Decimal Conversion
Number Conversion Number Conversion
„„
Binary to Decimal Conversion Binary to Decimal Conversion
Number Conversion Number Conversion
„„
Binary to Decimal Conversion Binary to Decimal Conversion
™
Example:
Convert binary 1011.1010
2
to decimal.
1011.1010
2
=
(1) 2
3
+ (1) 2
1
+ (1) 2
0
+ (1) 2
-1
+(1)2
-3
= 11.625
10
Number Conversion Number Conversion
„„
Decimal to Any Radix (Base) Conversion Decimal to Any Radix (Base) Conversion
1.1.
INTEGER DIGIT: INTEGER DIGIT: Repeated division by the radix & Repeated division by the radix & record the remainder record the remainder
2.2.
FRACTIONAL DECIMAL: FRACTIONAL DECIMAL: Multiply the number by the radix Multiply the number by the radix until the answer is in integer until the answer is in integer
Example: Example: 25.3125 to Binary 25.3125 to Binary
Integer Digit Integer Digit
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
MSB
L
SB
Number Conversion Number Conversion
„„
Binary to Octal Conversion (vice versa) Binary to Octal Conversion (vice versa)
1.1.
Grouping the binary position in groups Grouping the binary position in groups of of
three three
starting at the least significant starting at the least significant
position. position.
™™
Example: Example:
„„
Convert the following binary numbers to their Convert the following binary numbers to their octal equivalent (vice versa). octal equivalent (vice versa). a)a)
1001.1111 1001.1111
22
b) 47.3 b) 47.3
88
c)c)
1010011.11011 1010011.11011
22
„„
Answer: Answer: a)a)
11.74 11.74
88
b) 100111.011 b) 100111.011
22
c)c)
123.66 123.66
88
Number Conversion Number Conversion
„„
Binary to Hexadecimal Conversion (vice Binary to Hexadecimal Conversion (vice versa) versa)
1.1.
Grouping the binary position in 4 Grouping the binary position in 4
--
bit bit
groups, starting from the least groups, starting from the least significant position. significant position.
™™
Example: Example: „„
Convert the following binary numbers to Convert the following binary numbers to their hexadecimal equivalent (vice versa). their hexadecimal equivalent (vice versa). a)a)
10000.1 10000.1
22
b)b)
1F.C1F.C
1616
„„
Answer: Answer: a)a)
10.810.8
1616
b)b)
00011111.1100 00011111.1100
22
Binary Addition Binary Addition
0 + 0 = 0
S
um of 0 with a carry of 0
0 + 1 = 1
S
um of 1 with a carry of 0
1 + 0 = 1
Sum of 1 with a carry of 0
1 + 1 = 10
Sum of 1 with a carry of 1
Example:
11001
111
+ 1101
+ 11
100110
???
1’s complements of binary numbers 1’s complements of binary numbers
„„
Changing all the 1s to 0s and all the 0s to Changing all the 1s to 0s and all the 0s to 1s1s Example Example
: :
1 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 0 1
Binary number Binary number
0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0
1’s complement 1’s complement
2’s complements of binary numbers 2’s complements of binary numbers
„„
By adding 1 to the LSB of the 1’s complement By adding 1 to the LSB of the 1’s complement
„„
2’s complement = (1’s complement) + 1 2’s complement = (1’s complement) + 1
Example Example
: :
1 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0
Binary number Binary number
0 0 1 0 1 1 0 0 1 0 0 1 0 1 1 0 0 1
1’s complement 1’s complement
+ 1 + 1
Add 1 Add 1
0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0
2’s complement 2’s complement
Alternative method: Alternative method:
„„
Start from right (LSB), write all bits until Start from right (LSB), write all bits until you find the first bit 1 and then continue you find the first bit 1 and then continue the remaining bits with 1’s complement. the remaining bits with 1’s complement. Example: Example:
1 1 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0
1
st
bit 1
You write the 1
ST
2
bits from LSB
1
st
complement for
the remaining bits
Binary number 2’s c
o
mplement
Signed numbers Signed numbers
„„
Left most is the sign bit Left most is the sign bit
„„
0 is for positive, and 1 is for negative 0 is for positive, and 1 is for negative
„„
SignSign
--
magnitude magnitude
„„
0 0 0 1 1 0 0 1 = +25 0 0 0 1 1 0 0 1 = +25
sign bit magnitude bits sign bit magnitude bits
„„
1’s complement 1’s complement
„„
The negative number is the 1’s complement The negative number is the 1’s complement of the corresponding positive number of the corresponding positive number
„„
Example: Example:
+25 is 00011001 +25 is 00011001
--
25 is 11100110 25 is 11100110
Signed numbers Signed numbers
„„
2’s complement 2’s complement
„„
The positive number The positive number
––
same as sign same as sign
magnitude and 1’s complement magnitude and 1’s complement
„„
The negative number is the 2’s complement The negative number is the 2’s complement of the corresponding positive number. of the corresponding positive number.
Example: Example:
Express +19 and Express +19 and
--
19 in 19 in
i. sign magnitude i. sign magnitude ii. 1’s complement ii. 1’s complement iii. 2’s complement iii. 2’s complement
Arithmetic Operation With Arithmetic Operation With
Signed numbers Signed numbers
„„
Addition Addition
„„
Subtraction Subtraction
„„
Multiplication Multiplication
„„
Division
Find out !!!!
Division
Digital Codes Digital Codes
„„
BCD (Binary Coded Decimal) Code BCD (Binary Coded Decimal) Code
1.1.
Represent each of the 10 decimal Represent each of the 10 decimal digits (0~9) as a 4 digits (0~9) as a 4
--
bit binary code. bit binary code.
™™
Example: Example: „„
Convert 15 to BCD. Convert 15 to BCD.
1 5 1 5
0001 0101 0001 0101
BCDBCD
„„
Convert 10 to binary and BCD. Convert 10 to binary and BCD.
Digital Codes Digital Codes
„„
ASCII (American Standard Code for ASCII (American Standard Code for Information Interchange) Code Information Interchange) Code
1.1.
Used to translate from the keyboard Used to translate from the keyboard characters to computer language characters to computer language
Digital Codes Digital Codes
„„
The Gray Code The Gray Code
„„
Only 1 bit changes Only 1 bit changes
„„
Can’t be used in Can’t be used in arithmetic circuits arithmetic circuits
„„
Binary to Gray Code Binary to Gray Code and vice versa.
01010101
01100110
66
01110111
01010101
55
01100110
01000100
44
00100010
00110011
33
00110011
00100010
22
00010001
00010001
11
00000000
00000000
00
Gray Gray CodeCode
Binary Binary
Decimal Decimal
and vice versa.
Digital Codes Digital Codes
„„
Seven Segment Code Seven Segment Code
Arrangements of 7 segment LED display