Week 5 Number Systems
Week 5 Number Systems
Number Systems
• Number categories
– Many categories: natural, negative, rational, irrational and many
others important to mathematics but irrelevant to the
understanding of computing
• Number – unit belonging to an abstract mathematical
system and subject to specified laws of succession,
addition and multiplication
– Natural number is the number 0 or any other number obtained
adding repeatedly 1 to this number.
– A negative number is less than 0 and it is opposite in sign to a
positive number.
– An integer is any of positive or negative natural numbers
– A rational number is an integer or the quotient of any two
integer numbers
• is a value that can be expressed as a fraction
Number Systems …
• The base of number system represents the number
of digits that are used in the system. The digits
always begin with 0 and continue through one less
than the base
• Examples:
– There are two digits in base two (0 and 1)
– There are eight digits in base 8 (0 through 7)
– There are 10 digits in base 10 (0 through 9)
• The base determines also what the position of the
digits mean
Positional Notation
• It is a system of expressing numbers in which the digits are arranged in
succession and, the position of each digit has a place value and the number is
equal to the sum of the products of each digit by its place value
• Example:
– Consider the number 954:
• 9 * 102 + 5 * 101 + 4 * 100 = 954
– Polynomial representation - formal way of representing numbers, where X is the base
of the number:
• 9 * X2 + 5 * X 1 + 4 * X 0
• Formal representation – consider that the base of representation is B and the
number has n digits, where di represents the digit in the ith position.
– dn * Bn-1 + dn-1 * Bn-2 + …+ d2B +d1
– 642 is:
63 * 102 + 42 * 10 + 21 * 10 0
Other bases
6 x 8² = 6 x 64 = 384
+ 4 x 8¹ = 4 x 8 = 32
+ 2 x 8º = 2 x 1 = 2
= 418 in base 10
• We can check if the answer is correct by converting the both operands in base 10, adding them and comparing the result
2 5 3
• 10101011 is binary
The reason that 253 incanbase 8
be immediately converted in
octal and vice-versa is because 8 is power of 2
• There is a similar relationship between binary and
hexadecimal
Converting Binary to Hexadecimal
• Start at the rightmost binary digit and mark the digits in
groups of four
• Convert each group individually
3567 16
32 D E F
36 222 16
32 16
47 62 13
32 48
15 14
Review of Binary Values in
Computing Systems
• Modern computers are binary machines
• A digit in binary system is either 0 or1
• The binary values in a computer are encoded using
voltage levels:
– 0 is represented by a 0V signal (or low voltage)
– 1 is represented by a 5V signal (i.e. in TTL logic), or by a high
voltage signal.
• Bit – is a short expression for binary digit
• Byte – eight binary digits
• Word – a group of one or more bytes; the number of bits
in a word is the word length in a computer
Review Question 6
Convert number 11001111 to hexadecimal. The
answer is:
A.CF
B.BF
C.FC
D.I don’t know …
Review Question 7
Convert decimal number 375 to its octal
representation. The answer is
A.567
B.765
C.556
D.I don’t know …
Review Question 8
Convert decimal number 37 to its binary
representation. The answer is:
A.101001
B.100101
C.111000
D.I don’t know …
Fractions
• Representation and conversion of fractional numbers is
more difficult because there is not necessarily an exact
relationship between fractional numbers in different
number bases.
• Fractional numbers that can be represented exactly in one
number base, may be impossible to represent exactly in
another
• Example:
– The decimal fraction 1/3 is not represent-able as a decimal value
in base 10: 0.333333310…; this can be represented exactly in
base 3 as 0.13
– The decimal fraction 1/10 (or 0.110) cannot be represented
exactly in binary form. The binary equivalent begins:
0.0001100110012…
Fractions …
• The strength of each digit is B times the strength of its right
neighbor (where B is the base for a given number).
• If we move the number point to the right, the value of the number
will be multiplied by the base:
– 139010 is 10 times as large as 139.010
– The 1002 is twice as big as 102
• The opposite is also true – if we move the number point to the left
one place, then the value is divided by the base
• A given number .D1D2D3 …Dn will be represented as:
– D1 * B-1 + D2 * B-2 + D3 * B-3 + .. + DnB-n
– 0.2589 = 2 * (1/10) + 5 * (1/100) + 8 * (1/1000) + 9 *
(1/10000)
– 0.1010112 = (½) + (1/8) + (1/32) + (1/64)
Fractional Conversion Methods
• The intuitive method:
– Determine the appropriate weights for each digit, multiply each digit by its
weight and then add the values
• Example:
• convert 0.122013 to base 10 = (1/3) + 2 * (1/9) + 2 * (1/27) + (1/243) =
0.63374
– Convert the number in a natural number (and record what was the
multiplier) and then divide the result by the multiplier
• Example:
• convert 0.1100112 to base 10 – shifting the binary point six places to the right
and converting, we have: 32 + 16 +2 +1 = 51; shifting the point back is the
equivalent of 26 or 64, so we can obtain the final number by dividing 51 to 64
= 0.796875
• Variation of the division method shown earlier: we multiply the
fraction by the base value, repeatedly, and record, then drop the
values that move to the left of the point.
– This is repeated until the level of accuracy is obtained or until the value
being multiplied is zero
Fractions Base Conversion
0.828125
2
*
0.110101
1.656250 *
The 1 is saved as 2
result then dropped 1.312500 *
and the process 2
repeated 0.625000 *
2
1.250000 *
2
0.500000 *
2
1.000000
Fraction Conversions between Bases
power of two
• The conversion between bases where one base is
an integer power of the other can be performed for
fractions by grouping the digits in the smaller base
as before
• For fractions, the grouping must be done from the
left to right; the method is otherwise identical
• Example:
– Convert 0.101112 to base 8: 0.101_110 = 0.568
– Convert 0.1110101 to base 16: 0.1110_1010 = 0.EA16
Review Question 9
Convert binary number 0.11 to its decimal value.
The answer is:
A.0.1
B.0.5
C.0.75
D.I don’t know …
Review Question 10
Convert decimal number 0.33 in it binary
representation. Use maximum 8 bit precision after
the point. The result is:
A.0.01010100
B.0.11001100
C.0.11111111
D.I don’t know …
Review Question 11
Consider binary number 0.01010100. Compute its
decimal value. The answer is:
A.0.33
B.0.328125
C.0.5
D.I don’t know …