Number System
Number System
By:
Dilum Bandara
Dept. of Computer Science & Engineering
University of Moratuwa
1
Outline
p Decimal
p Binary
p Octal
p Hexadecimal
p Number base conversion
© CSE 2
Humans vs. Computers
p It is not surprising that our number
system is based on units of TEN,
n Since nature provided man with five fingers on
each of 2 hands.
© CSE 4
Number Bases
Number Base Symbols
System
Binary 2 0, 1
Octal 8 0, 1, 2, 3, 4, 5, 6, 7
Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
A, B, C, D, E, F
© CSE 5
Decimal Number System
p The number 4567 in base 10 means:
© CSE 6
Positional notations
p In general, the relationship between a
digit, its position & the base of the number
system is expressed by the following
formula:
© CSE 7
Weight Associated with Digit Position
© CSE 9
Binary number system
p Base of the binary number system is 2
p Symbols are 0 & 1
© CSE 10
Octal number system
p Base of the octal number system is 8
p The symbols are 0, 1, 2, 3, 4, 5, 6 & 7
© CSE 11
Hexadecimal number system
p The base is 16
p The symbols are
n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
© CSE 13
Terminology cont…
7 6 5 4 3 2 1 0
1 1 0 1 1 0 0 1
MSB – Most
Significant Bit LSB – Least
Significant Bit
© CSE 14
Number Base Conversion
p It is necessary to convert from one
number system to another
p Example:
n Windows Calculator
© CSE 15
Decimal to Binary conversion - Integers
p Convert 910 into binary
9/2 = 4 r = 1
4/2 = 2 r = 0
2/2 = 1 r = 0
1/2 = 0 r = 1
p 910 = 10012
© CSE 16
Decimal to Binary conversion cont…
p Convert 2710 to binary
p 2710 = 110112
© CSE 17
Decimal to Binary – Fractions
p Example 1: Represent 0.5 10 in binary
0.5×2 = 1.0
0.0×2 (this ends the process)
So 0.5 10 = 0.12
© CSE 19
Binary to Decimal conversion cont…
p Example 3: Convert 11101.012 to decimal
© CSE 21
Example 4:
p Convert 111001 2 to decimal
p 1110012 = 5710
© CSE 22
Example 5:
p Represent 123410 in hexadecimal
p 123410 = 4D216
© CSE 23
Binary to Octal conversion
p Example 6: convert 110100112 in to octal
11 | 010 | 011
011 | 010 | 011 - add extra bit
3 2 3
110100112 = 3238
© CSE 24
Summary
p Different number systems
n Decimal, Binary, Octal & Hexadecimal
p Terminology
n Bit, LSB, MSB
p Number base conversion
© CSE 25