0% found this document useful (0 votes)
15 views34 pages

Week 5 Number Systems

The document provides an overview of number systems, including natural, negative, rational, and irrational numbers, and explains the concept of positional notation. It covers various bases such as binary, octal, decimal, and hexadecimal, detailing methods for converting between these systems and performing arithmetic operations. Additionally, it discusses the representation of fractional numbers and their conversion challenges across different bases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views34 pages

Week 5 Number Systems

The document provides an overview of number systems, including natural, negative, rational, and irrational numbers, and explains the concept of positional notation. It covers various bases such as binary, octal, decimal, and hexadecimal, detailing methods for converting between these systems and performing arithmetic operations. Additionally, it discusses the representation of fractional numbers and their conversion challenges across different bases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 34

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

What if 642 has the base of 13?


+ 6 x 13² = 6 x 169 = 1014
+ 4 x 13¹ = 4 x 13 = 52
+ 2 x 13º = 2 x 1 = 2
= 1068 in
base 10
642 in base 13 is equivalent to 1068 in base
10
Binary, Octal and Hexadecimal
• Decimal base has 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8,
9)
• Binary is base 2 and has two digits (0 and 1)
• Octal is base 8 and has 8 digits (0, 1, 2, 3, 4, 5, 6,
7)
• Hexadecimal is base 16 and has 16 digits (0, 1, 2,
3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)
Converting Octal to Decimal
• What is the decimal equivalent of octal
number 642?

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

• Remember that octal base has only 8 digits


(0, 1, 2, 3, 4, 5, 6, 7)
Converting Hexadecimal do Decimal
• What is the decimal equivalent of the hexadecimal
number DEF?

D x 16² = 13 x 256 = 3328


+ E x 16¹ = 14 x 16 = 224
+ F x 16º = 15 x 1 = 15
= 3567 in base 10

• Remember that hexadecimal base has 16


digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D,
E, F)
Converting Binary to Decimal

• What is the equivalent decimal of the binary


10110 number?
1 x 24 = 1 x 16 = 16
+ 0 x 23 = 0x8 =0
+ 1 x 22 = 1x4 =4
+ 1 x 21 = 1x2 =2
+ 0 x 20 = 0x1 =0
= 22 in base 10
• Remember that binary base has only 2
digits (0, 1)
Review Question 1
What is octal number 11 in decimal representation?
A.7
B.8
C.9
D.I don’t know …
Review Question 2
What is the decimal representation of binary number
1110?
A.8
B.14
C.16
D.I don’t know …
Review Question 3
What is decimal representation of hexadecimal
number FF?
A.10
B.255
C.256
D.I don’t know …
Arithmetic in Binary
• The rules of arithmetic are analogous in other
basis as in decimal base
Should read 1+1=0 with a carry
Addition
of 1 similar to base 10 where 9 +
1 = 0 with a carry of 1 = 10 1 1 0 0
+ + + +
1 0 1 0
10 1 1 0

-1 can be stated as 1 with a


Subtraction
borrow of 1. Leading 1 we
consider to be the sign, so 11 1 1 0 0
means -1
- - - -
1 0 1 0
0 1 11 0
Addition in Binary
• Base 2: 1+1 operation - the rightmost digit reverts to 0 and there is a carry into the next position to the left

• We can check if the answer is correct by converting the both operands in base 10, adding them and comparing the result

111 Carry Values


0101
+1011
10000
Subtracting in Binary
• The rules of the decimal base applies to binary as well. To
be able to calculus 0-1, we have to “borrow one” from the
next left digit.
• More precisely, we have to borrow one power of the base
12
0202
1010
-0111
0011
• You can check if the result is correct by converting the
operands in decimal and making the calculus.
Review Question 4
• Add 4 bit number 0100 with 0111. The answer is:
A.1001
B.1011
C.1110
D.I don’t know …
Review Question 5
• Subtract 4 bit number 0100 from 1111. The
answer is:
A.1001
B.1011
C.1110
D.I don’t know …
Power of two Number Systems
• Binary and octal numbers
have a very special relation Binary Octal Decimal
between them: given a binary 000 0 0
number, can be read in octal 001 1 1
and given an octal number 010 2 2
can be read in binary (i.e. 011 3 3
have 753 in octal, in binary 100 4 4
you have 111 101 011 by 101 5 5
replacing each digit by its 110 6 6
binary representation) 111 7 7

• Table represents counting in 1000 10 8


1001 11 9
binary with octal and decimal
1010 12 10
representation
Converting Binary to Octal
• Start at the rightmost binary digit and mark the digits in groups of
three
• Convert each group individually

10101011 10 101 011

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

10101011 1010 1011


A B
10101011 is AB in base 16
Converting Decimal to Other Bases
• Involves dividing by the base into which you convert the
number
• Algorithm:
– Dividing the number by the base you get a quotient and a
reminder
– While the quotient is not zero:
• Divide the decimal number by the new base
• Make the remainder the next digit to the left in the answer
• Replace the original dividend with the quotient
• The base 10 number 3567 is what number in base 16?
Converting Decimal to Hexadecimal
• 3567 in decimal is DEF in hexadecimal

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 …

You might also like