Lcture 2 - Number-Systems
Lcture 2 - Number-Systems
CHAPTER 2
NUMBER SYSTEMS
2
INFORMATION REPRESENTATION (1/4)
Examples
Represent yes or no: use 0 and 1
Represent the 4 seasons: 0, 1, 2 and 3
Examples:
2 bits represent up to 4 values (00, 01, 10, 11)
3 bits rep. up to 8 values (000, 001, 010, …, 110, 111)
4 bits rep. up to 16 values (0000, 0001, 0010, …., 1111)
CS2100
5
INFORMATION REPRESENTATION (4/4)
CS2100
6
DECIMAL (BASE 10) SYSTEM (1/3)
CS2100
7
DECIMAL (BASE 10) SYSTEM (2/3)
In general,
CS2100
7
DECIMAL (BASE 10) SYSTEM (3/3)
CS2100
9
OTHER NUMBER SYSTEMS
Binary (base 2)
Weights in powers of 2
Binary digits (bits): 0, 1
Octal (base 8)
Weights in powers of 8
Octal digits: 0, 1, 2, 3, 4, 5, 6, 7.
Hexadecimal (base 16)
Weights in powers of 16
Hexadecimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
CS2100
7
Binary (BASE 2) SYSTEM
CS2100
7
OCTAL (BASE 8) SYSTEM
CS2100
7
HEXADECIMAL (BASE 16) SYSTEM
CS2100
13
BASE-R TO DECIMAL CONVERSION
Easy!
1101.1012 = 123 + 122 + 120 + 12-1 + 12-3
572.68 = 5 82 + 7 81 + 2 80 + 6 8-1
Method 1
Sum-of-Weights Method
Method 2
Repeated Division-by-2 Method (for whole
numbers)
Repeated Multiplication-by-2 Method (for
fractions)
CS2100
15
SUM-OF-WEIGHTS METHOD
CS2100
16
REPEATED DIVISION-BY-2
To convert a whole number to binary, use
successive division by 2 until the quotient is 0. The
remainders form the answer, with the first
remainder as the least significant bit (LSB) and the
last as the most significant bit (MSB).
2 43
(43)10 = (101011)2
2 21 rem 1 LSB
2 10 rem 1
2 5 rem 0
2 2 rem 1
2 1 rem 0
0 rem 1 MSB CS2100
17
REPEATED MULTIPLICATION-BY-2
To convert decimal fractions to binary, repeated
multiplication by 2 is used, until the fractional
product is 0 (or until the desired number of decimal
places). The carried digits, or carries, produce the
answer, with the first carry as the MSB, and the last
as the LSB.
Carry
(0.3125)10 = (.0101)2 0.31252=0.625 0 MSB
0.6252=1.25 1
0.252=0.50 0
0.52=1.00 1 LSB
CS2100
18
CONVERSION BETWEEN DECIMAL
CS2100
19
BINARY TO OCTAL/HEXADECIMAL
CONVERSION
END