Number Systems

Download Report

Transcript Number Systems

Number Systems
Number Systems

The total number of allowable symbols in a number system is called the radix or base of the
system.
 Decimal Numbers:
 radix = 10 (symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
 Binary Numbers:
 radix = 2 (symbols: 0, 1)
 Hexadecimal Numbers:
 radix = 16 (symbols: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
 Positional Notation: The radix point separates the integer part of the number from the
fractional part of the number. Each position represents a power of the radix.
 Example: decimal number
1256.932=
(1 x 103) + (2 x 102) + (5 x 101) + (6 x 100)+ (9 x 10-1) + (3 x 10-2) + (2 x 10-3)
 Example: binary number
(1 1 0 1 0 . 1 1 0 1)2 =
(1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (0 x 20) + (1 x 2-1) + (1 x 2-2) + (0 x 2-3) + (1 x 2-4)
= 26.8125 = 26 13/16
Conversion Calculator
http://fclass.vaniercollege.qc.ca/web/mathematics/real/Calculators/BaseConv_Calc_1.htm
Number Systems
2
Binary Numbers

Assume 1-bit numbers: the largest number is binary 1


Only two different numbers can be represented: 0 AND 1
Assume 2-bit numbers: the largest number is binary 11

Four different numbers can be represented:
(a) 00 – 0 (b) 01 – 1 (c)10 – 2 (d) 11 - 3
 Assume 3-bit numbers: the largest number is binary 111

Eight different numbers can be represented:
000 – 0 001 – 1 010 – 2 011 – 3 100 – 4 101 – 5 110 – 6 111 – 7

What’s the largest number in binary that can be represented
using 4 bits? What is it’s decimal equivalent?
Number Systems
3
Hexadecimal Numbers


Assume 4-bit binary numbers: Sixteen different numbers can be represented:
Binary Decimal Hexadecimal
0000
0
0
0001
1
1
0010
2
2
0011
3
3
0100
4
4
0101
5
5
0110
6
6
0111
7
7
1000
8
8
1001
9
9
1010
10
A
1011
11
B
1100
12
C
1101
13
D
1110
14
E
1111
15
F
Sample Hexadecimal Number:
(A 1 F . 1 C)16 = (A x 162) + (1 x 161) + (F x 160) + (1 x 16-1) + (C x 16-2)
= (10 x 162) + (1 x 161) + (15 x 160)+ (1 x 16-1) + (12 x 16-2)
= 2591 28/256
Number Systems
4
Binary <--> Hexadecimal Conversions

Binary to Hex: group digits into blocks of 4
(01000010101001010110.11110001)2 = (?)16
0100 0010 1010 0101 0110 . 1111 0001
= (4 2 A 5 6 . F 1)16
 Hex to Binary: convert each hex value to binary
(AF5.2C)16 = (?)2
A F 5 . 2 C = (1010 1111 0101 . 0010 1100)2
 Another binary to hex:
(11010.1101)2 = (?)16
0001 1010 . 1101= (1 A . D)16
Number Systems
5
Radix Divide Techniques

Decimal-to-Base x Integer Conversions





Decimal-to-Binary Conversions:


Divide the given integer successively by the required radix, noting
the remainder at each step.
The quotient at each step becomes the new dividend for the
subsequent division.
Stop the division process when the quotient becomes zero.
Collect the remainders from each step (last to first) and place
them left to right to form the required number.
(245)10 = (?)2
Decimal-to-Hexadecimal Conversions:

(245)10 = (?)16
Number Systems
6
Radix Divide Techniques
(245)10 = (?)2
= 11110101
=1*27+1*26+1*25+1*24+
0*23+1*22+0*21+1*20
=128+64+32+16+0+4+0+1
=245
Number Systems
245/2
122/2
61/2
30/2
15/2
7/2
3/2
1 /2
122
61
30
15
7
3
1
0
STOP
1
0
1
0
1
1
1
1
7
Radix Divide Techniques
(245)10 = (?)16
= F516
245/16 15
5
15/16 0
15F
STOP
=15*161+5*160=245
Number Systems
8
Summary of base conversions

Base 2 to base 10


Base 16 to base 10



base 2: Use the division-remainder procedure with 2 as the divisor
base 16: Use the division-remainder procedure with 16 as the divisor
Base 2 to base 16


Multiply each hex digit by its power of 16 and add up the individual
values
Base 10 to


Multiply each binary digit by its power of 2 and add up the individual
values
Convert each block of 4 binary digits into the equivalent base 16 value
Base 16 to base 2

Number Systems
Expand each hex value into the equivalent binary
9