Вы находитесь на странице: 1из 9

Introduction to Machine Organization:

Number Systems
Computer Hardware

• DATA REPRESENTATION
• Since data stored in memory is a string of 0’s and 1’s which are fetched and
manipulated by the CPU, there must be a way of representing numbers and
characters in memory
• POSITIONAL NUMBER SYSTEM
• A number is represented by a string of digits where each digit position has
an associated weight
• Example: decimal number system
D = (d2 x 102) + (d1 x 101) + (d0 x 100) = d2d1d0
• 541 = 5 x 102 + 4 x 101 + 1 x 100
= 500 + 40 + 1
= 541
• 1.25 = 1 x 100 + 2 x 10–1 + 5 x 10–2
= 1 + .2 + .05
= 1.25

©Philip Zamora CS 11 Introduction to Computer 2


Science
Computer Hardware
Cont…
• DIFFERENT NUMBER SYSTEMS
Base Number System
2 Binary
8 Octal
10 Decimal
16 Hexadecimal
– Representation of Positive Numbers
• Usually, computers are based on the binary number system
11012 = (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
= (1 x 8) + (1 x 4) + 0 + (1 x 1)
= 1310
1.1012 = (1 x 20) + (1 x 2–1) + (0 x 2–2) + (1 x 2–3)
but 2–1 = ½ = 0.5;
2–2 = 1/22 = ¼ = 0.25
2–3 = 1/23 = 1/8 = 0.125
= (1 x 1) + (1 x .5) + (0 x 0.25) + (1 x 0.125)
= 1 + 0.5 + 0 + 0.125
= 1.62510

©Philip Zamora CS 11 Introduction to Computer 3


Science
Computer Hardware
Cont…
– Representation of Negative Numbers
• One way: using the signed magnitude system
which consists of: magnitude and a symbol indicating whether a number is positive or
negative
Example: +24 +14.25
-24 -14.25
• For binary number system, the leftmost bit is used to indicate sign: 0 is positive; 1 is
negative
Example: 0001 01012 = +2110
1001 01012 = -2110
– Representation of Characters
• Uses ASCII  7 bits are usually used to represent a character
Example: B  100 00102
C  100 00112
“BCC”
1 0000 1010 0001 1100 0011

©Philip Zamora CS 11 Introduction to Computer 4


Science
Computer Hardware
Cont…
Radix Base Conversion
Base Number System Values
2 Binary 0, 1
8 Octal 0, 1, 2, 3, 4, 5, 6, 7
10 Decimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
16 Hexadecimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

If we have a number in base b:


dn-1 dn-2 dn-3 ….. d1 d0
Then the equivalent decimal number is computed as follows:
(dn-1 x bn-1) + (dn-2 x bn-2) + (dn-3 x bn-3) +…..+ (d1 x b1) + (d0 x b0)
Examples:
1012 = 1 x 22 + 0 x 21 + 1 x 20 A616 = 10 x 161 + 6 x 160
= 4+0+1 = 160 + 6
= 510 = 16610

©Philip Zamora CS 11 Introduction to Computer 5


Science
Computer Hardware
Cont…
Conversion from base 10 to base b, the process is reversed.
Example:
1710 ÷ 2 = 8 remainder 1
8 ÷ 2 = 4 remainder 0
4 ÷ 2 = 2 remainder 0
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1 read upwards
1710 = 100012

1710 ÷ 8 = 2 remainder 1
2 ÷ 8 = 0 remainder 2
1710 = 218

©Philip Zamora CS 11 Introduction to Computer 6


Science
Computer Hardware
Cont…
Conversion from base b1 to b2 if either b1 or b2 is divisible by the other
Example:
1. base 2 to base 8 - groups of 3 from the right, then get base 8 equivalent
100012
10 0012
2 18
2. base 2 to base 16 - groups of 4
100012
1 00012
1 116

Higher to lower: base 8 to base 2


2 5 48 but 28 = 0102
58 = 1012
48 = 1002
010 101 1002
2548 = 1010 11002

©Philip Zamora CS 11 Introduction to Computer 7


Science
Some Applications
• Network addresses
• Memory address locations
• Color definitions

©Philip Zamora CS 11 Introduction to Computer 8


Science
©Philip Zamora CS 11 Introduction to Computer 9
Science

Вам также может понравиться