Beruflich Dokumente
Kultur Dokumente
Chapter Objectives
At the completion of this chapter, you should be able to: identify the different types of numbers; convert between denary and other base; convert between binary, octal and hexadecimal; understand the column system and number bases; understand modular arithmetic; hexadecimal, octal addition.
1-1
CMA101
1.1 Introduction
In this chapter, we start to explore various sets of numbers which are used to represent data in real life problems. Namely, natural numbers, integers, rational, irrational, real and complex numbers. Numbers are used to represent quantities, measurement, and others in our surroundings. They are essential representations of data that will be processed by computer systems to produce useful information. The computer system, being a digital electronic device, has to handle data in binary numbers. In binary numbers, each binary digit has only two states rather than ten states in decimal numbers. Therefore, binary, octal and hexadecimal number systems are dealt with in subsequent parts of the chapter.
Rational Real numbers which can be expressed as the ratio of 2 integer Example: 1/2, 0.57, -3
Real Can be represented by points a the straight line Example: 2.31, 5 , 6 Complex No real number that can satisfy the equation X2 = 1 , 5 , 88 1Example:
1-2
CMA101
423524 = 4 x 105 + 2 x 104 + 3 x 103+ 5 x 102 + 2 x 101 + 4 x 100 The Power of Magnification for each individual column is derived as, Power of Magnification = Base(Column no - 1)
1-3
CMA101
1110012= 1 x 25 + 1 x 24 + 1 x 23 + 1 x 20 = 32 + 16 + 8 + 1 = 5710 Example: Convert 4BEEF816 to denary 6 5 4 256 162 E 3 2 16 161 F 1 1 160 8
The octal number is obtained by reading the last integer 7 and upwards to include all remainders; 47510 = 7338
1-4
CMA101
Convert 47510 to binary Example: 475 2 237 2 118 2 59 2 29 2 14 2 7 2 3 2 1 2 0 47510 = 1110110112 remainder 1 remainder 1 remainder 0 remainder 1 remainder 1 remainder 0 remainder 1 remainder 1 remainder 1
1-5
CMA101
000 001 010 011 100 101 110 111 No. of symbols in octal = 2 no. of binary bits
Octal 0 1 2 3 4 5 6 7
Binary
We need three binary bits to represent symbols in octal! Likewise, one octal number will produce three binary bits. To prove it, try whether 3748 = 011 111 1002?
Now can you see why 1101011002 = 1AC16? 0001 1 1010 1100 A C
1-6
CMA101
0 . 0 0 0 1 1 0 On the other hand, how can we convert (110.000110)2 to denary real numbers? Method: i. Write down the value of each bit (binary digit).
ii. Multiply the value by every bit. iii. Take the sum of products. 4 1 2 1 1 0 2-12-22-32-42-52-6 .0 0 1
4*1 + 2*1 + 0*1 + 0*0.5 + 0*0.25 + 0*0.12 5 + 1*0.0625 + 1*0.03125 + 0*0.015625 = 6.09375 1-7
CMA101
1.9
Octal Arithmetic
We only cover octal addition. The sum of two octal numbers can be reduced by the usual addition algorithm to the repeated addition of two digits (with possibly a carry of 1). The following table shows the addition of Octal number. ++ 0 1 2 3 4 5 6 7 0 0 1 2 3 4 5 6 7 1 1 2 3 4 5 6 7 10 2 2 3 4 5 6 7 10 11 3 3 4 5 6 7 10 11 12 4 4 5 6 7 10 11 12 13 5 5 6 7 10 11 12 13 14 6 6 7 10 11 12 13 14 15 7 7 10 11 12 13 14 15 16
The sum of two octal digits, or the sum of two octal digits plus 1, can be obtained by: i. Finding their decimal sum; and
ii. Modifying the decimal, if it exceeds 7, by subtracting 8 and carrying 1 to the next column. Example: 58 + 68 + 28 = 158 58 + 68 28 Decimal sum Modification - 8 Octal sum
1-8
CMA101
If the base exceeds ten, we need mentally to change each hexadecimal letter digit to its decimal form when finding the decimal sum, and each decimal difference greater than nine to its hexadecimal form when modifying the decimal sum. A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 Example: A16 + 916 A16 + 916 Decimal sum 19 Modification - 16 Octal sum 1316
1-9
CMA101
Points to Remember
The various sets of numbers include: Natural numbers Integers Rational numbers Irrational numbers Real numbers Complex numbers The higher the precision required the longer the processing time in computer systems. 4 number systems Decimal (Denary) Binary Octal Hexadecimal Additional of Octal and Hexadecimal Convert from other base to decimal integer Step 1. Write down the weight of each digit; Step 2. Multiply each weight and each digit; Step 3. Take the sum of the product. Convert from decimal integer to other bases Step 1. Divide the decimal integer by the desired base; Step 2. Write down the remainder; Step 3. Repeat dividing until a quotient 0; Step 4. Read the remainders from bottom upwards. Octal and hexadecimal numbers are used as a shorthand for binary numbers. Each octal digit can be expressed as 3 binary digits Each hexadecimal digit can be expressed as 4 binary digits. Use modular arithmetic when the data is finite.
1 - 10
CMA101
[1] [1]
1 - 11
CMA101 C1003
8. Convert: a. ABC Hexadecimal to OCTAL b. 3974 Denary to HEXADECIMAL 9. Convert: a. 7456 Octal to HEXADECIMAL b. 9E7 Hexadecimal to DENARY 10. Convert: a. 8543 Denary to OCTAL b. 9AD Hexadecimal to OCTAL 11. Convert: a. A25 HEXADECIMAL to BINARY b. 549 DENARY to OCTAL c. 3527 OCTAL to HEXADECIMAL 12. Convert: a. 5391 Denary to HEXADECIMAL b. 6A5 Hexadecimal to OCTAL 13. Convert: a. 5743 Denary to HEXADECIMAL b. ABC Hexadecimal to OCTAL 14. Convert the following: (You MUST show all workings.) a. 110100102 to Hexadecimal b. 54A16 to Denary c. 10178 to Binary d. 16710to Binary 15. Convert the following: a. 1752648to base 16 b. 110110 to base 16 c. 728 28 to base 10 d. B0016 + 1F16 to base 2 [1] [1] [2] [2] [2] [2] [2] [2] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1]
1 - 12
CMA101
16. a.
b. Express the number 4610 in binary c. Express the number 9210 in binary d. Express in binary the result of multiplying 1001101112 by 410 17. Convert the following: a. 3578 to base 16 b. 101110to base 16 c. 5048 28to base 10 d. 6A16 + D0016 to base 2 18. What is the BASE of the number system where 36 + 27 = 65? 19. By converting to BINARY, evaluate the HEXADECIMAL expression: 7B + EA. Give your answer in HEXADECIMAL. 20. a. Evaluate (7 * 4 + 6 * 5) mod 11
b. Solve (3p = 7) mod 11 23. Evaluate ((4 * 6) + (35 DIV 4)) MOD 11
1 - 13