Topic 2:: Numbering System & Codes
Topic 2:: Numbering System & Codes
Topic 2:: Numbering System & Codes
NUMBERING SYSTEM
& CODES
INTRODUCTION
The binary system and decimal system is
most important in digital system.
Decimal - Universally used to represent
quantities outside a digital system.
Its means, the will be situations decimal
values must be converted to binary values
before entered to digital system.
Example : Calculator / Computer
2.1 DECIMAL NUMBERING
SYSTEM
Decimal system is composed of 10 numerals
or sysmbols.
Basic number
2 7 4 6 . 2
MSD LSD
Most significant digit Least significant digit
Ex 2:
101112 + 1112 = ________
SUBTRACTION
Four conditions in binary subtraction
0 - 0 = 0
0 - 1 = 1 borrow 1
1 - 0 = 1
1 - 1 = 0
Ex 1:
10012 – 102 = 1112
Ex 2:
1010112 – 11112 =__________
Conversions of Binary Numbers
24 + 23 + 22 + 21 + 20 = 16 + 8 + 2 + 1
= 2710
Decimal to Binary conversions
Ex: Ex:
1238 4578
+ 3218 + 2458
4448
Decimal-to-Octal Conversion
Decimal integer can be converted to octal by
using the same repeated-division method
with a division factor of 8.
Octal –to- Binary conversion
Binary to Octal conversion
HEXADECIMAL NUMBERING
SYSTEM
The hexadecimal number system uses base
16.
It has 16 possible digit symbols.
It uses the digits 0 through 9 plus the letters
A, B, C, D, E and F as the 16 digit symbols.
Basic number
Ex: Ex:
3 316 2 0 D 316
+ 4 716 + 1 2 B C16
7 A16
Hexadecimal number - Subtraction
(Pengurangan)
Ex: Ex:
4 416 3 2 5 516
- 1 716 - 3 1 8 216
2 D16
Hexadecimal-To-Decimal Conversion
16 20
16 1 4
2010 = 1416
Hexadecimal-to-Binary Conversion
Like the octal number system, the
hexadecimal number system is used primarily
as a “shorthand” method for representing
binary numbers.
It is a relatively simple matter to convert a
hex number to binary .
Each hex digit is converted to its four-bit
binary equivalent.
Ex:
111010012 = __________
00101101001111002 =___________
Binary-to-Hexadecimal Conversion
The binary number is grouped into groups of
four bits, and each group is converted to its
equivalent hex digit.
Zero are added, as needed to complete a
four-bit group.
Ex:
1012 = 0101
= 516
Summary
+10 00001010
+ 5 00000101
+15 00001111
Negative Number (-) Positive Number
Exp:
-10 – (+5) = - 15
- 10 11110110 11110110
- (+5) 00000101 + 11111011
-15 111110001
Negative Number (-) Negative Number
Exp:
-10 – (-5) = -10 + (5)
=-5
-10 11110110
- (- 5) + 00000101
- 5 11111011
BCD Code
BCD – Binary Coded Decimal
8 7 4 (decimal)
9 6
Step 2 : Change decimal number to binary
number.
1001 0110BCD 8421 = 11000002
Binary Number – to – BCD 8421 Code
Exp:
Convert 10010102 to BCD 8421
code.
Step 1: Change binary number to decimal
number.
10010102 = 7410
Binary Hex 0 1 2 3 4 5 6 7
1000 8 Bs Can ( 8 H X h x
1001 9 HT Em ) 9 I Y i y
1010 A LF Sub . : J Z j z
1011 B VT Esc + ; K k
1100 C FF FS , < L l
1101 D CR GS - = M m
1110 E SO RS . > N n
1111 F SI US / ? O o
Exp:
An operator is typing in a BASIC program
at the keyboard of a certain
microcomputer. The computer converts
each keystroke into its ASCII code and
stores the code as a byte in memory.
Determine the binary strings that will be
entered into memory when operator types
in the following BASIC statement:
GOTO 25
Solution:
Locate each character (including the
space) and record ASCII code.
G 01000111
O 01001111
T 01010100
O 01001111
(space)00100000
2 00110010
5 00110101
*0 was added to the leftmost bit of each ASCII code because the
Codes must be stored as bytes (eight bits).
Exercise :
1.The following message encode in ASCII
code. What the meaning of this code ?
a) 54 4F 4C 4F 45 47
b) 48 45 4C 4C 4F
c) 41 50 41 4B 48 41 42 41 52