Sie sind auf Seite 1von 13

CHAPTER 1 : NUMBER BASES

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

CHAPTER 1 : NUMBER BASES

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.

1.1.1 Number Sets

Natural Positive integers Example: 3, 71

Integers Whole numbers Example: 3, -71

Rational Real numbers which can be expressed as the ratio of 2 integer Example: 1/2, 0.57, -3

Irrational Real numbers which are not rational Example: 2 ,

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 Level of Precisions


Some translator software have two levels of precisions in storing real numbers. Namely single-precision and double precision.

1-2

CMA101

CHAPTER 1 : NUMBER BASES

1.2.1 Single Precision


The real number is calculated to 8 and displayed to 7 significant figures. Example: = = 3.1415926 3.141593 calculated displayed

1.2.2 Double Precision


The computer will need longer processing time to produce double precision numbers. The real number is calculated to 16 and displayed on the screen to 15 significant figures. Example: = = 3.141592653589793 calculated 3.14159265358979 displayed

1.3 Number Base


A fundamental counting group consists of a number of various symbols. Counting Groups Binary 0, 1 Octal Hexadecimal Denary 0, 1, 2, 3, 4, 5, 6, 7 0, 1, 2, 3, ... 9, A, B, C, D, E, F 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Symbols of the Group 2 8 16 10 No. of Symbols

1.4 Column System


Enable us to represent any conceivable number by combining numerals and zeros. For example, 423524 is derived from this column system: Column No Value Power of Magnification Numerals 6 5 4 100 102 5 3 2 10 101 2 1 1 100 4

100,000 10,000 1,000 105 4 104 2 103 3

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

CHAPTER 1 : NUMBER BASES

CMA101

1.5 Conversion from Other Bases to Denary


We can use this column system to convert a number in other bases to its equivalence in Denary. Example: Convert 1110012 to denary 6 32 25 1 5 16 24 1 4 8 23 1 3 4 22 0 2 2 21 0 1 1 20 1

Column No Value Power of Magnification Numerals

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

Column No Value Power of Magnification Numerals 4BEEF816

1048576 65536 4096 165 4 164 B 163 E

= 4 x 165 + 11 x 164+ 14 x 163+ 14 x 162+ 15 x 161+ 8 x 160 = 497636910

1.6 Conversion from Denary to Other Bases


To convert a denary number to other bases, we do a repeated division by the desired base until a quotient 0 is obtained. Example: Convert 47510 to octal 8 8 475 59 remainder 3 8 7 remainder 3 0 remainder 7

The octal number is obtained by reading the last integer 7 and upwards to include all remainders; 47510 = 7338

1-4

CMA101

CHAPTER 1 : NUMBER BASES

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.7 Conversion Among Other Base


We have illustrated the conversions between denary and other bases. How about converting a binary number to an octal number? Or, an octal number to a hexadecimal one?

1.7.1 Binary to Octal


We know that 910 = 10012 and 910 = 118 so, we can conclude that 10012 = 118. To convert a binary number to an octal number in this case will involve a lot of calculations. Is there a better way to convert these numbers? Yes. How many binary bits do we need to represent an octal digit?

1-5

CHAPTER 1 : NUMBER BASES

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?

1.7.2 Binary to Hexadecimal


Following the same argument, it is not so difficult to see why we need to have four binary bits to represent one hexadecimal number. No. of symbols in Hexadecimal = 2 no .of
binary bits

Now can you see why 1101011002 = 1AC16? 0001 1 1010 1100 A C

1.7.3 Conversion Between Octal and Hexadecimal


Since every octal number will produce three binary bits, and every four binary bits will produce one hexadecimal number. We can make use of the binary base as the conversion medium to convert a hexadecimal number to an octal number or vice versa. Example Convert 7338 to a hex no. Step 1: Convert 7338 to a binary number. 111 011 011 Step 2: Step 3: Convert this binary number to a hex. 1DB Hence, 7338 = 1DB1 Rearrange this binary number into 4-bit groups. 0001 1101 1011

1-6

CMA101

CHAPTER 1 : NUMBER BASES

CHAPTER 1 : NUMBER BASES

1.8 Real Number


In real numbers, e.g. (4.75)10, the 4 is an integer part while 0.75 is a fractional part. What is the way to convert 0.75 to a binary fraction? The method is to multiply 0.75 by 2 continuously until the fraction becomes zero or the degree of accuracy is satisfied. 4.75 = 4 + 0.75 = (100)2 + (0.11)2 = (100.11)2 2 2 4 2 1 0 0 0 0.11 Let's look at another example. (6.1)10 to be converted to binary places. 6.1 = 6 + 0.1 = (110)2 + (0.000110)2 = (110.000110)2 correct to 6 binary places. 2 2 6 3 1 0 1 0.1 * 2 0.2 * 2 0.4 * 2 0.8 * 2 1.6 * 2 1.2 * 2 0.4 0.75 * 2 1.5 * 2 1.0

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

CHAPTER 1 : NUMBER BASES

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.10 Hexadecimal Arithmetic


As with the octal system, we cover only hexadecimal addition. The sum of two hexadecimal digits, or the sum of two hexadecimal digits plus 1, can be obtained by: i. Finding their decimal sum; and ii. Modifying the decimal, if it exceeds 15, by subtracting 16 and carrying 1 to the next column.

1-8

CMA101

CHAPTER 1 : NUMBER BASES

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.11 Modular Arithmetic


In our daily life, there are many counting/measuring systems around us. We know that 100cm is not the same as 100 inches. It's because the measuring units are different, however, we do not intend to cover the conversions of this kind. To demonstrate how modular arithmetic works is to give a test first: If Peter starts work at 8 o'clock in the morning and works for 8 hours, at what time will Peter finish work? 4 o'clock in the afternoon, right? But how you worked that one out? Because the clock only has 12 hours, once the shorthand reaches 12, it will restart from 0. The numbers we see on the clock-face must be less than or equal to 12. This is a finite set or finite arithmetics. To show it mathematically, we add 8 hours to 8 o'clock, and divide 16 by the modules number 12, the remainder 4 will be the answer we want. 8 + 8 (16) mod 12 Example: = = 16 4

(11 + 3 + 7 + 9)mod 12 30/12 30 mod12= = 2 remainder 6 6

1-9

CHAPTER 1 : NUMBER BASES

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

CHAPTER 1 : NUMBER BASES

1.12 Past Year Questions


1. Express the number 7478 in: a. Binary b. Denary c. Hexadecimal 2. Convert showing all working; a. 21.625 denary to binary b. 2AE hexadecimal to denary c. 16.62 octal to binary d. 567 octal to binary e. 684 denary to hexadecimal 3. Convert the following: a. 157 denary to binary b. 1100110101 binary to octal c. ACD hexadecimal to denary d. 2464 octal to hexadecimal 4. Convert the following: a. 101 101 101 Binary to Octal b. DAB Hexadecimal to Denary c. 2839 Denary to Hexadecimal d. 7453 Octal to Hexadecimal 5. Express the denary number 567: a. in binary b. in hexadecimal 6. Express the number 1038: a. in binary b. hexadecimal 7. Convert: a. 274 Octal to DENARY b. DA3 Hexadecimal to OCTAL [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1] [1]
[ 1 ]

[1] [1]

1 - 11

CHAPTER 1 : NUMBER BASES

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

CHAPTER 1 : NUMBER BASES

16. a.

Express the number 2310 in binary

[1] [1] [1] [2]

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

[2] [2] [2] [2] [2]

[2] [1] [2] [1] [2] [1] [2] [3]

b. Solve (3 * p = 8) mod 11 21. a. Evaluate (7 * 3 + 5 * 2 + 2 * 1) mod 11

b. Evaluate (3 * p) mod 5 for p = 0, 2 and 4 22. a. Evaluate (8 * 5 + 7 * 6) mod 11

b. Solve (3p = 7) mod 11 23. Evaluate ((4 * 6) + (35 DIV 4)) MOD 11

1 - 13

Das könnte Ihnen auch gefallen