Comarch
Comarch
Chapter 10
Number Systems
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Decimal System
• System based on decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to
represent numbers
• For example the number 83 means eight tens plus three:
83 = (8 * 10) + 3
• The number 4728 means four thousands, seven hundreds, two tens,
plus eight:
4728 = (4 * 1000) + (7 * 100) + (2 * 10) + 8
• The decimal system is said to have a base, or radix, of 10. This
means that each digit in the number is multiplied by 10 raised to a
power corresponding to that digit’s position:
83 = (8 * 101) + (3 * 100)
4728 = (4 * 103) + (7 * 102) + (2 * 101) + (8 * 100)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Decimal Fractions
• The same principle holds for decimal fractions, but negative powers
of 10 are used. Thus, the decimal fraction 0.256 stands for 2 tenths
plus 5 hundredths plus 6 thousandths:
0.256 = (2 * 10-1) + (5 * 10-2) + (6 * 10-3)
• A number with both an integer and fractional part has digits raised to
both positive and negative powers of 10:
442.256 = (4 * 102) + (4 + 101) + (2 * 100) + (2 * 10-1) + (5 * 10-2)
+ (6 * 10-3)
• Most significant digit
– The leftmost digit (carries the highest value)
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Table 10.1
Positional Interpretation of a Decimal
Number
4 7 2 2 5 6
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Positional Number Systems
• Each number is represented by a string of digits in which
each digit position i has an associated weight ri, where r
is the radix, or base, of the number system.
• The general form of a number in such a system with
radix r is
( . . . a3a2a1a0.a-1a-2a-3 . . . )r
where the value of any digit ai is an integer in the range
0 < ai < r. The dot between a0 and a-1 is called the radix
point.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Table 10.2
Positional Interpretation of a Number in
Base 7
Position 4 3 2 1 0 –1
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
The Binary System
• Only two digits, 1 and 0
• Represented to the base 2
• The digits 1 and 0 in binary notation have the same meaning as in decimal notation:
02 = 010
12 = 110
• To represent larger numbers each digit in a binary number has a value depending on its
position:
102 = (1 * 21) + (0 * 20) = 210
112 = (1 * 21) + (1 * 20) = 310
1002 = (1 * 22) + (0 * 21) + (0 * 20) = 410
and so on. Again, fractional values are represented with negative powers of the radix:
1001.101 = 23 + 20 + 2-1 + 2-3 = 9.62510
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Converting Between Binary and Decimal
• Binary notation to decimal notation:
– Multiply each binary digit by the appropriate power of 2 and add the
results
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Integers 1/2
For the integer part, recall that in binary notation, an integer represented by
bm-1bm-2 . . . b2b1b0 bi = 0 or 1
N = 2 * N1 + R0 R0 = 0 or 1
Next, we divide the quotient N1 by 2. Assume that the new quotient is N2 and the new
remainder R1. Then
N1 = 2 * N 2 + R1 R1 = 0 or 1
so that
N = 2(2N2 + R1) + R0 = (N2 * 22) + (R1 * 21) + R0
If next
N2 = 2N3 + R2
we have
N = (N3 * 23) + (R2 * 22) + (R1 * 21) + R0
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Integers 2/2
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Figure 10.1
Examples of Converting from Decimal
Notation to Binary Notation for Integers
Quotient Remainder
11 = 5 1
2
5 = 2 1
2
2 = 1 0
2
1 = 0 1
2
10112 = 1110
(a) 1110
Quotient Remainder
21 = 10 1
2
10 = 5 0
2
5 = 2 1
2
2 = 1 0
2
1 = 0 1
2
101012 = 2110
(b) 2110
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Figure 10.1 Examples of Converting from Decimal
Notation to Binary Notation for Integers
Fractions (1 of 2)
For the fractional part, recall that in binary notation, a number with a
value between 0 and 1 is represented by
0.b-1b-2b-3 . . . bi = 0 or 1
and has the value
(b-1 * 2-1) + (b-2 * 2-2) + (b-3 * 2-3) . . .
This can be rewritten as
2-1 * (b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . ))
Suppose we want to convert the number F (0 < F < 1) from
decimal to binary notation. We
know that F can be expressed in the form
F = 2-1 * (b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . ))
If we multiply F by 2, we obtain,
2 * F = b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . )
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Fractions (2 of 2)
From this equation, we see that the integer part of (2
* F), which must be either 0 or 1 because 0 < F < 1,
is simply b-1. So we can say (2 * F) = b-1 + F1, where
0 < F1 < 1 and where
0.62 2 = 1.24 1
0.24 2 = 0.48 0
0.48 2 = 0.96 0
0.96 2 = 1.92 1
0.92 2 = 1.84 1
0.5 2 = 1.0 1
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Hexadecimal Notation 1/2
• Binary digits are grouped into sets of four bits, called a nibble
• Because 16 symbols are used, the notation is called hexadecimal and the 16
symbols are the hexadecimal digits
• Thus
2C16 = (216 * 161) + (C16 * 160)
= (210 * 161) + (1210 * 160) = 44
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Table 10.3 Decimal (base 10)
0
Binary (base 2)
0000
Hexadecimal (base 16)
0
Decimal, Binary, 1
2
0001
0010
1
2
and Hexadecimal 3
4
0011
0100
3
4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
16 0001 0000 10
17 0001 0001 11
18 0001 0010 12
31 0001 1111 1F
100 0110 0100 64
255 1111 1111 FF
256 0001 0000 0000 100
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Hexadecimal Notation 2/2
In most computers,
binary data occupy some It is extremely easy to
It is more compact than
multiple of 4 bits, and convert between binary
binary notation
hence some multiple of a and hexadecimal notation
single hexadecimal digit
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Summary
Number Systems
Chapter 10
• Converting between
• The decimal system binary and decimal
• Positional number – Integers
– Fractions
systems
• The binary system • Hexadecimal notation
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved
Copyright
This work is protected by United States copyright laws and is provided solely
for the use of instructions in teaching their courses and assessing student
learning. dissemination or sale of any part of this work (including on the
World Wide Web) will destroy the integrity of the work and is not permit-
ted. The work and materials from it should never be made available to
students except by instructors using the accompanying text in their
classes. All recipients of this work are expected to abide by these
restrictions and to honor the intended pedagogical purposes and the needs of
other instructors who rely on these materials.
Copyright © 2019, 2016, 2013 Pearson Education, Inc. All Rights Reserved