MTES3013 TAJUK2 Number Base

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 74

LECTURE WEEK 6

2. Number Bases
Convert any base-a number to base-b
number up to base-16.
Make connection between numbers of
various bases
Converting to Base 10:
Notice that the last problem was base 6, which is
lower than our base. What if the number was in
base 12 (which is larger than our base)? In base
12, there should be 12 different symbols, starting
with 0. So we could list 0,1,2,3,4,5,6,7,8,9, but
then what? We cannot use 10 and 11 because
they are not different symbols, they are a
combination of two symbols.
In our text, the following symbols for base 12 are
used: 0,1,2,3,4,5,6,7,8,9,T,E. To remember this,
think the T stands for ten and the E stands for
eleven.

2
OCTAL TO DECIMAL CONVERTION
Convert from octal to decimal by multiplying each octal digit by its positional
weight.

Example 1: Convert 1638 to decimal value


Solve = 1 x (82 ) 6 x (81 ) 1 x (80 )
= 1 x 64 + 6 x 8 + 1 x 1
= 11510

Example 2: Convert 3338 to decimal value


Solve = 3 x (82 ) 3 x (81 ) 3 x (80 )
= 3 x 64 + 3 x 8 + 3 x 1
= 21910
DECIMAL TO OCTAL CONVERTION

Convert from decimal to octal by using the repeated division method used
for decimal to binary conversion.
Divide the decimal number by 8
The first remainder is the LSB and the last is the MSB.
Example : convert 35910 to Decimal Value

Solve = 35910 = ?8
= 359 44 balance 7 LSB
8
= 44 5 balance 4
8
= 58 0 balance 5 MSB
... Answer = 5478
OCTAL TO BINARY CONVERTION
Convert from octal to binary by converting each octal digit to a
three bit binary equivalent
Octal digit 0 1 2 3 4 5 6 7
Binary 000 000 000 000 000 000 000 000
Equivalent

Convert from binary to octal by grouping bits in threes starting


with the LSB.
Each group is then converted to the octal equivalent
Leading zeros can be added to the left of the MSB to fill out the
last group.
Converting to Base 10:
2. Convert 123E12 to base 10.
In base 12, the positional values are
. . . 123 , 122 , 12 , 1.
Writing 123E12 in expanded form:
123E12 = (1x123 ) + (2x122 ) + (3x12) + (11x1)
= (1x1728) + (2x144) + (3x12) + (11x1)
= 1728 + 288 + 36 + 11
= 2063

6
Converting to Base 10:
Basically, converting to base 10 involved writing
a number in expanded form and multiplying to
find the value of each digit. Then find the sum
of all of the values.
To see more examples of converting to base 10,
look at page 162 in the text, Examples 2,3, and
4.

7
Converting from Base 10 to another base:
What if we want to convert the other way? It
would make sense that we would do the
opposite operation division.

8
Converting from Base 10 to another base:
3. Convert 146 ( which is in base 10) to base 5.
The positional values in base 5 are
. . . 54 , 53 , 52 , 5 , 1 or . . . 625 , 125 , 25 , 5 , 1
The highest power of 5 that is less than or equal
to 146 is 53 or 125. Divide 146 by 125.
146/125 = 1 with remainder 21.
Therefore, there is 1 group of 125 in 146.
( 1 is the first digit in the answer )

9
Converting from Base 10 to another base:
3 continued: Next divide the remainder, 21, by 25
(the next lower positional-value of 5).
21/25 = 0 with remainder 21
Therefore, there are 0 groups of 25 in 21.
(0 is the 2nd digit in the answer)
Next divide the remainder, 21, by 5 (the next
lower positional-value of 5).
21/5 = 4 with remainder 1
Therefore, there are 4 groups of 5 in 21 with 1
unit remaining.
(4 is the 3rd digit in the answer)
10
Converting from Base 10 to another base:
3 continued: The answer is:
146 = (1 x 125) + (0 x 25) + (4 x 5) + (1 x 1)
= (1 x 53) + (0 x 52) + (4 x 5) + (1 x 1)
= 10415
Note: We place a subscript 5 to the right of
1041 to show that it is a base 5 number.

11
Converting from Base 10 to another base:
4. Convert 1695 to base 12.
The positional values in base 12 are
. . .123 , 122 , 12 , 1 or . . . 1728 , 144 , 12 , 1
The highest power of 12 that is less than or
equal to 1695 is 144. Divide 1695 by 144.
1695/144 = 11 with remainder 111
Therefore, there are 11 groups of 144 in 1695.
( E, the symbol for 11 in base 12, is the first digit
in the answer)

12
Converting from Base 10 to another base:
Next, divide the remainder, 111, by 12 (the next
lower positional-value of 12).
111/12 = 9 with remainder 3
Therefore, there are 9 groups of 12 in 111 and 3
units remaining.
(9 is the 2nd digit in the answer)
1695 = (E x 122 ) + ( 9 x 12 ) + ( 3 x 1 )
= E9312

13
Converting from Base 10 to another base:
More examples converting from base 10 to
another base can be found in the text on pages
162-164, Examples 5-7.

14
OCTAL TO BINARY CONVERTION
Convert from octal to binary by converting each octal digit to a
three bit binary equivalent
Octal digit 0 1 2 3 4 5 6 7
Binary 000 000 000 000 000 000 000 000
Equivalent

Convert from binary to octal by grouping bits in threes starting


with the LSB.
Each group is then converted to the octal equivalent
Leading zeros can be added to the left of the MSB to fill out the
last group.
BINARY TO OCTAL CONVERSION
Can be converted by grouping the binary bit in group of three starting
from LSB
Octal is a base-8 system and equal to two the power of three, so a digit
in Octal is equal to three digit in binary system.
HEXADECIMAL NUMBER SYSTEM

The hexadecimal system uses base 16. Thus, it has 16 possible digit symbols. It uses
the digits 0 through 9 plus the letters A, B, C, D, E, and F as the 16 digit symbols.

16 4 163 16 2 161 16 0 16 1 16 2 16 3 16 4 16 5

Use to represent long binary numbers in computers and


microprocessors.
These digits can use to program machine language.
BINARY TO OCTAL CONVERSION
Can be converted by grouping the binary bit in group of three starting
from LSB
Octal is a base-8 system and equal to two the power of three, so a digit
in Octal is equal to three digit in binary system.
HEXADECIMAL TO OCTAL CONVERTION
There is two ways to convert it:-
i. Hexadecimal Decimal Octal
ii. Hexadecimal Binary Octal
i. Hexadecimal Decimal Octal
i. Hexadecimal Decimal Octal
If it was just to save space we would use a higher base than 16.
Base-16 is a convenient way for humans to "see" binary as we would
only need to learn 16 different patterns.
0 - 0000 | 8 - 1000
1 - 0001 | 9 - 1001
2 -0010 | A - 1010
3 - 0011 | B - 1011
4 - 0100 | C - 1100
5 - 0101 | D - 1101
6 - 0110 | E - 1110
7 - 0111 | F - 1111
If we know what pattern goes with what number/letter we can
convert a large Binary number to Hexadecimal (readmoreof this
comment)

23
Decimal Number 4-bit Binary Number Hexadecimal Number

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 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 (1+0)

17 0001 0001 11 (1+1)

Continuing upwards in groups of four


24
25
4.4 Computation in Other Bases

It was mentioned before that computers


perform calculations in base 2. This
section covers computations in base 2
and other bases.

26
Addition in Other Bases:
In some examples, the book uses addition
tables from each base to solve addition
problems. In this course, we will not be using
addition tables. In this course, you will not be
asked to use addition tables, and you will not be
allowed to use them when taking a test.
In the long run, it is faster to learn to add
numbers without the tables.

27
Addition in Other Bases:
To add in bases other that base 10, we will add
as if we were in base 10, and then convert the
answer to the given base. Once the sum is
converted to the given base, then we can
record it under the problem.
It is much easier to explain this by showing an
example. The following slides will show how to
add in bases other than 10.

28
Addition in Other Bases:

1. Add 44 7 Start: 4 + 5 = 910 = 12 7


+ 65 7

29
Addition in Other Bases:
1

1. Add 44 7 Start: 4 + 5 = 910 = 12 7


+ 65 7 Record the 2 and carry the 1.
2

30
Addition in Other Bases:
1

1. Add 44 7 Start: 4 + 5 = 910 = 12 7


+ 65 7 Record the 2 and carry the 1.
2
1 + 4 + 6 = 1110 = 14 7

31
Addition in Other Bases:
1

1. Add 44 7 Start: 4 + 5 = 910 = 12 7


+ 65 7 Record the 2 and carry the 1.
142 7
1 + 4 + 6 = 1110 = 14 7
Record the 14.

32
Addition in Other Bases:
1

1. Add 44 7 Start: 4 + 5 = 910 = 12 7


+ 65 7 Record the 2 and carry the 1.
142 7
1 + 4 + 6 = 1110 = 14 7
Record the 14.
The problem is completed.

33
Addition in Other Bases:

2. Add 341 5
1 + 1 = 2 10 = 2 5
+ 341 5

34
Addition in Other Bases:

2. Add 341 5
1 + 1 = 2 10 = 2 5
+ 341 5
2 Record the 2.

35
Addition in Other Bases:

2. Add 341 5
1 + 1 = 2 10 = 2 5
+ 341 5
2 Record the 2.
4 + 4 = 8 10 = 13 5

36
Addition in Other Bases:
1

2. Add 341 5 1 + 1 = 2 10 = 2 5
+ 341 5
Record the 2.
32
4 + 4 = 8 10 = 13 5
Record the 3 and carry
the 1.

37
Addition in Other Bases:
1

2. Add 341 5 1 + 1 = 2 10 = 2 5
+ 341 5
Record the 2.
32
4 + 4 = 8 10 = 13 5
Record the 3 and carry
the 1.
1 + 3 + 3 = 7 10 = 12 5

38
Addition in Other Bases:
1

2. Add 341 5 1 + 1 = 2 10 = 2 5
+ 341 5
Record the 2.
1232 5
4 + 4 = 8 10 = 13 5
Record the 3 and carry
the 1.
1 + 3 + 3 = 7 10 = 12 5
Record the 12. You are
finished. 39
Addition in Other Bases:
Study Examples 4 and 5 on pages 168 and 169
in the text. These are more examples of
addition in other bases.

40
Subtraction in Other Bases:
Subtraction can be performed in other bases
relatively easily. Remember that when you
have to borrow, you borrow the amount of the
base given in the problem. For example, if you
are subtracting in base 3, when you borrow, you
borrow 3.

41
Subtraction in Other Bases:

3. Subtract 536 7
- 124 7

42
Subtraction in Other Bases:

3. Subtract 536 7 64=2


- 124 7

43
Subtraction in Other Bases:

3. Subtract 536 7 6 4 = 2, record the 2.


- 124 7
2

44
Subtraction in Other Bases:

3. Subtract 536 7 6 4 = 2, record the 2.


- 124 7 32=1
2

45
Subtraction in Other Bases:

3. Subtract 536 7 6 4 = 2, record the 2.


- 124 7 3 2 = 1, record the 1.
12

46
Subtraction in Other Bases:

3. Subtract 536 7 6 4 = 2, record the 2.


- 124 7 3 2 = 1, record the 1.
12
51=4

47
Subtraction in Other Bases:

3. Subtract 536 7 6 4 = 2, record the 2.


- 124 7 3 2 = 1, record the 1.
412 7
5 1 = 4, record the 4.

48
Subtraction in Other Bases:

3. Subtract 536 7 6 4 = 2, record the 2.


- 124 7 3 2 = 1, record the 1.
412 7
5 1 = 4, record the 4.
The problem is
completed.

49
Subtraction in Other Bases:
Notice how that was no different than if we
would have been calculating in base 10. That is
because we did not have to borrow.
Lets look at an example that involves
borrowing.

50
Subtraction in Other Bases:

4. Subtract 1221 3
- 202 3

51
Subtraction in Other Bases:

4. Subtract 1221 3 We need to borrow.


- 202 3

52
Subtraction in Other Bases:
1

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3.

53
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
3 + 1 = 4.

54
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
3 + 1 = 4.
4 2 = 2.

55
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
2 3 + 1 = 4.
4 2 = 2. Record the 2.

56
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
2 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1.

57
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
12 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1. Record the 1.

58
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
12 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1. Record the 1.
2 2 = 0.

59
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
012 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1. Record the 1.
2 2 = 0. Record the 0.

60
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
012 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1. Record the 1.
2 2 = 0. Record the 0.
1 0 = 1.

61
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
1012 3 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1. Record the 1.
2 2 = 0. Record the 0.
1 0 = 1. Record the 1.

62
Subtraction in Other Bases:
1 4

4. Subtract 1221 3 We need to borrow.


- 202 3 Cross out the 2, borrow
one group of 3. Add the
1012 3 3 + 1 = 4.
4 2 = 2. Record the 2.
1 0 = 1. Record the 1.
2 2 = 0. Record the 0.
1 0 = 1. Record the 1.
The problem is
complete. 63
Subtraction in Other Bases:
Study examples 6 and 7 on page 169 in the
text. These are examples of subtraction in
other bases.
Just remember to borrow the amount of the
base in the problem.

64
Multiplication in Other Bases:
To multiply in bases other that base 10, we will
multiply as if we were in base 10, and then
convert the answer to the given base. Once the
product is converted to the given base, then we
can record it under the problem.
It is much easier to explain this by showing an
example. The following slides will show how to
multiply in bases other than 10.

65
Multiplication in Other Bases:

5. Multiply 123 5
x 45

66
Multiplication in Other Bases:

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45

67
Multiplication in Other Bases:
2

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45 Record the 2 and carry
2 the 2.

68
Multiplication in Other Bases:
2

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45 Record the 2 and carry
2 the 2.
(4 x 2) + 2 = 10 10 = 20 5

69
Multiplication in Other Bases:
22

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45 Record the 2 and carry
02 the 2.
(4 x 2) + 2 = 10 10 = 20 5
Record the 0 and carry
the 2.

70
Multiplication in Other Bases:
22

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45 Record the 2 and carry
02 the 2.
(4 x 2) + 2 = 10 10 = 20 5
Record the 0 and carry
the 2.
(4 x 1) + 2 = 6 10 = 11 5

71
Multiplication in Other Bases:
22

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45 Record the 2 and carry
1102 5 the 2.
(4 x 2) + 2 = 10 10 = 20 5
Record the 0 and carry
the 2.
(4 x 1) + 2 = 6 10 = 11 5
Record the 11.

72
Multiplication in Other Bases:
22

5. Multiply 123 5 3 x 4 = 12 10 = 22 5
x 45 Record the 2 and carry
1102 5 the 2.
(4 x 2) + 2 = 10 10 = 20 5
Record the 0 and carry
the 2.
(4 x 1) + 2 = 6 10 = 11 5
Record the 11.
The problem is complete. 73
THE END

74

You might also like