[go: up one dir, main page]

0% found this document useful (0 votes)
77 views25 pages

Number System

The document provides an overview of number systems including Decimal, Binary, Octal, and Hexadecimal, along with their bases and symbols. It explains the concepts of positional notation, weight associated with digit positions, and the terminology used in computing such as bits, LSB, and MSB. Additionally, it covers methods for converting between different number bases, including examples of conversions from decimal to binary and vice versa.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
77 views25 pages

Number System

The document provides an overview of number systems including Decimal, Binary, Octal, and Hexadecimal, along with their bases and symbols. It explains the concepts of positional notation, weight associated with digit positions, and the terminology used in computing such as bits, LSB, and MSB. Additionally, it covers methods for converting between different number bases, including examples of conversions from decimal to binary and vice versa.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 25

Number Systems

CS101- Computer Systems

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.

p Computers use binary


n They have only electronic or electromechanical
switches.
n These switches have only 2 states, either ON
or OFF
© CSE 3
Distinguishing Number Systems
p The characteristic which distinguish one
number system from another is called the
base (or radix)
p The base or radix, of a number system is:
n the number of different digits that can occur in
each position in the number system.
n this is the number of symbols in a system
n Example: Base 10 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

© 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:

4567 = four thousand five hundred and sixty seven


= 4000 + 500 + 60 + 7
= (4 × 1000) + (5 × 100) + (6 × 10) + (7 × 1)
= (4 × 103) +(5 × 102) +(6 × 101)+(7 ×100)

© 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:

DIGIT × BASE POSITION #

© CSE 7
Weight Associated with Digit Position

When expressed as a series of digits, the


value of a number is determined by
considering the "weight" associated with
the position of each
© CSE
digit. 8
p The number 512.49 in base 10 means:

512.49 = 500 + 10 + 2 + 0.40 + 0.09


= (5×100)+(1×10) + (2×1) + (4× 0.1)+
(9 × 0.001)
= (5×102) + (1×101) + (2×100) + (4× 10-1) +
(9 ×10-2)

© CSE 9
Binary number system
p Base of the binary number system is 2
p Symbols are 0 & 1

p The number 1101.11 in base 2 means:


1101.01
= (1×23)+(1×22)+(0×21)+(1×20)+(0×2-1)
+ (1×2-2)

© 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

p The number 456.41 in base 8 means:


475.01
=(4×82)+(7×81)+(5×80)+(0×8-1)+(1× 8-2)

© 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

p The number 1FA.4C in base 16 means:


1FA.4C
=(1×162)+(F×161)+(A×160)+(4×16-1)
+(C×16-2)
= (1×162)+(15×161)+(10×160)+(4×16-1)
+(12×16-2)
© CSE 12
Terminology
p Computers represent numbers as a series
of switches which store a pattern of ON's &
OFF's, representing the binary digits 1 & 0.
p Each of these digits is called a BIT (BInary
digiT)
7 6 5 4 3 2 1 0
1 1 0 1 1 0 0 1

© 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

p Example 2: Represent 0.1 10 in binary


n 0.110 = 0.000110011001 2
n = 0.00011101
© CSE 18
Binary to Decimal conversion - Integers
The decimal value D of a binary word is given as:
m i 0
D = B m2 + ...+ B i 2 +... + B 0 2
where:
m is the position of the MSB
B is the binary value of the bit in position i

© CSE 19
Binary to Decimal conversion cont…
p Example 3: Convert 11101.012 to decimal

p We will calculate the position value for


each binary digit & then sum theoe values
p We write the position values above each
digit.
4 3 2 1 0 -1 -2
Position 2 2 2 2 2 2 2
Values 16 8 4 2 1 0.5 0.25
Binary Digits 1 1 1 0 1 . 0 1
© CSE 20
Example 3: cont…
p 11101.01
= (1×24)+(1×23)+(1×22)+(0× 21)+(1×20)
+(0×2-1)+(1×2-2)
= (1×16)+(1×8)+(1×4)+(0×2)+(1×1)
+(0×0.5) +(1×0.25)
= 16+8+4+0+1+0+0.25
= 29.25

© 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

p You should go through everything in the


note

© CSE 25

You might also like