You are on page 1of 16

CHAPTER - 3 NUMBER SYSTEM INTRODUCTION: Number Systems have evolved over ages.

They enable us to count and have led onward to arithmetic and other branches of Mathematics. A process of evolution has produced a system based on ten digits (decimal systems), which is now a universally accepted system. This is not, however, the only system possible. Others based on 12 or 5 digits have been used in the past. For certain purposes, a binary system (2 digits) is preferred. This applies particularly in the computer field, where counting is, done electric-ally. Here two stage operations are most easily identified and handled; for example, a switch may be forward or backward, a magnetic material may change state, a light may come on or go out. Again, in certain computer applications, an octal system (8 digits) may be used, or even above decimal system (16 digits) to reduce the complexity of certain operations. In the decimal system, there are ten basic symbols or digits starting from zero through 1 and ending up in 9. Each digit represents an increasing number of units. This number series of ten digits is called Arabic numerals but other numerals and digits could have been easily used in their places. When it is necessary to specify quantities greater than 9, more than one place of numerals is used, with a convention indicating a higher weightage for different positions of digits; for instance, after 9 the combination of '10' is used followed by 11' etc. In the binary system, this change over to multiple digits is restored to earlier in view of the reduced number of digits. Therefore, we would count as: 0, 1, 10, 11 (11 is read as one - one and not eleven in order to avoid confusion with decimal numbers). After 11 the next binary number is not 12 because there is no '2 in the binary scheme. We have 100, 101, 110 and so on. In each system, the number of digits in use is called the Base or Radix for the system. The weightage for the numeral number is least in the position at the extreme right and increases exponentially in each position towards the left. That is, the numeral on the extreme right is given a weight of R0 . Then next numeral to its left has a weightage of R 1 the digit following has a weightage of R2 etc. (Where R is the Radix for the system). RADIX-EQUATION: In the Binary System, 2 is the BASE or RADIX of the system. The radix or base of any system of numbers is the number of different symbols that can be used in any digit position e.g. Decimal Symbols 0,1,2,3,4,5,6,7,8,9 (Radix 10) Octal Symbols 0,1,2,3,4,5,6,7, (Radix 8) Hexadecimal Symbols 0,1,2,3,4,5,6,7,8,9, A,B,C, D,E,F (Radix 16). The Radix is always higher than the largest symbol by a value of1. i. e., R = 1 + S

Where R = Radix and S = Largest symbol e.g., 9 in decimal system. Decimal System: This is the system used in every day life and uses a radix of 10 i.e., there are ten symbols 0,1,2,3,4,5,6,7,8,9. To write large numbers in this system the digits are given positional as well as numerical values, e.g., 234 = 2 X 100 + 3 X 10 + 4 X 1 OR 234 = 2 X (10)2 + 3 X (10)l + 4 (10)o Binary System: The Binary System has a radix of 2, and uses the digits 0 and 1. The binary number 1001= 1 X (2)3+ 0 X (2)2+0 X (2)1+1 X (2)o = 1 X 8+0 X 4+0 X 2+1 X 1 = 9 This is equivalent to 9 in the decimal system. Large binary numbers are difficult to handle and conversion into octal or hexadecimal numbering system is often made for convenience. Table 1 shows how decimal number can be expressed as powers of 2, how these powers can be represented by a 1 in the appropriate zone, and how the decimal number is written on its equivalent binary forms. (Table 1 Please see next page) Octal System: The Octal System, which has a radix of 8, uses the digits 0, 1, 2, 3, 4, 55 6, 7, for example (737)8 = 7(8)2 + 3(8)1+ 7(8)o = 7 X 64 + 3 X 8 + -1 X 1 = (479)10 Hexadecimal System: This system uses a radix of 16 and uses the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F e.g. (23)16 = 2 (16) 1 + 3 (16)o (35)10 in the decimal system. The suffixes 8, 10 and 16 represent the radices of the octal, decimal and hexadecimal systems respectively. This is the concise yet explicit method of representing number in different

numbering systems. For example, the number 737 without suffix could mean one of the following decimal numbers. 737 using decimal system 479 using octal system 1,847 using hexadecimal system. Table - 1 Decimal Notation 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Powers of two 20 21 21+20 22 22+20 22+21 22+21+20 23 23+20 23+21 23+21+20 23+22 23+22+20 23+22+21 23+22+21+20 24 24 16 Zone . . . . . . . . . . . . . . . . . 23 8 Zone . . . . . . . . 1 1 1 1 1 1 1 1 0 22 4 Zone . . . . 1 1 1 1 0 0 0 0 1 1 1 1 0 21 2 Zone . . 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 20 1 Zone . 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Binary notation. 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000

In general using a radix of R digits a number is represented by: (dn X Rn + (dn- 1 XRn-1) . . . . (d1 X R1 where + (d3 XR3 ) + (d2 X R2 ) +

+ (do 7, R0) . . . . . . . . (2) d0 d1 d2 d3 . . dn represents the digit in the ,, ,, ,, . . . . . . . . ,, R0 R1 R2 R3 . . Rn position. ,, ,, ,, . . ,,

etc.

After decimal (R=10) and Binary (R=2) the other most used system is octal R = 8). The decimal point, the binary point and the octal point are specific names for Radix Point. RADIX CONVERSION:

Whereas the decimal system is normally used in day-to-day transactions, computers and other machines use the binary system of numbers. Therefore, a method of converting numbers from one system to another is required. The conversion methods are given in detail below:

Conversion from Binary to Decimal Numbers: Since each of the digits in a bina7 number has a weight corresponding to increasing power of 2 (20 21 , 22, etc., reading from right to left) we can use the following procedurea) digit. Write 1,2,4,8,16 under the digits of the binary number writing from right to left under each

b) If a zero appears in any digit position of the binary number, erase out the decimal weight for that position. c) Add the remaining weights to get the decimal equivalent.

For example, binary 101 can be converted to its decimal equivalent as follows: Step 1 - 101 Step 2 - 421 Step 3 - 401 Step 4 - 4 + 0 + 1 = 5 This method tends to be somewhat inconvenient for long binary numbers. The following method is somewhat more convenient and can be applied. For numbers greater than one: Example Convert (10111)2 to a decimal number.

So, (10111)2 = 1 X 20 + 1 X 21 + 1 X 22 + 0 X 23 + 1 X 24 = 1 + 2 + 4 + 0 + 16 = (23)10

For numbers less than one Rule Example : Convert (010111)2 to a decimal number

(0.10111)2 Check: (0.10111)

(0.71875)10

Answer

1 X 2-1 + 0 X 2-2 + 1 X 2-3 + 1 X 2-4 + 1 X 2-5 0.5 + 0 + 0.125 + 0.0625 + 0.03125 (0.71875) 10 Further examples of conversion of Binary Fractions to Decimal Fractions: (a) For short fraction direct calculation can be used i.e. (0.1)2 = 2-1, (0001)2 = 2-2 (0.001) = 2-3 etc. e.g., (000101)2 = 2-1 + 2-3 = 0.5 + 0.125 = 0.62510 (b) For longer fractions the above method becomes laborious and a better way is required. This method is in fact, the reverse of the second method for converting decimal fractions to binary fractions given above. (i) (ii) (iii) (iv) Write the binary fraction in a column with the least significant digit at the top. Divide the least significant digit by 2 and write the answer on the next line. This answer together with the digit on this line makes a new number which is now divided by 2 and the answer put is on the next line. The process is continued until the binary point is reached when a final division by 2 is made to give the answer required.

e.g. Convert (0.1101)2 to decimal 1 0.5 0.25 0.625 divided by 2 gives 0.5 together with 0 stays at 0.5, 0.5 divided by 2 gives 0.25 together with 1 gives 1.25, 1.25 divided by 2 gives 0.625 together with 1 gives 1.625, 1.625 divided, by 2 gives = .8125 Thus (0.1101)2 is equivalent to (0.8125)10. Conversion from Decimal to Binary: For smaller number this can be done by Inspection of the binary column values. i.e., the first column has the value 1, the second 2, the third 3 etc. For example decimal number 3 is made up of 8+4+2+1, so that binary number is 1111. This conversion by inspection may be facilitated by using a table such as shown below: Decimal Number 8 31 53 25 (32) 0 0 1 24 916) 0 1 1 23 (8) 1 1 0 22 (4) 0 1 1 21 (2) 0 1 0 20 (1) 0 1 1

Using this table the binary equivalents of decimal numbers up to 63 may be determined. e.g. The binary equivalent of 8 is 1000 -do31 is 011111 -do53 is 110101 For large numbers this method becomes laborious and an alternative method is found by referring to general expression of the binary number. This expression is d 2n + dn-12n-1 ++ d323 + d 22+ d121 + d020 Dividing the expression by 2 gives dn2 n-1 + dn-12 . + d221 + d120 + remainder d0 i.e., the least significant do is isolated.
n n-2

Thus, continual division by 2 isolates each digit in turn. Example Convert decimal number 77 to a binary number. 77/2 38/2 19/2 9/2 4/2 2/2 1/2 = 38 remainder = 1 = 19 remainder = 0 = 9 remainder =1 = 4 remainder =1 = 2 remainder =0 = 1 remainder =0 = 0 remainder =1

Since the first division gives the least significant digit the binary number is read from the bottom upwards i.e., (77)10 = (01001101)2. A more popular way to convert decimal numbers to binary numbers is the double - dabble method. In the double dabble method you progressively divide the decimal number by 2, writing down the remainder after each division. The remainders, taken in reverse order, form the binary number. To convert 9 to a binary number, progressively divide by 2 as follows :

9/2 = 4 with a remainder of 1 4/2 = 2 with a remainder of 0 2/2 = 1 with a remainder of 0 1/2 = 0 with a remainder of 1 In the first step you divide 9 by 2 to get 4 with a remainder of 1. Next divide the result of first division (4) . by 2 to get 2 with a remainder of 0. You continue in this fashion, progressively dividing, the result of each division by 2, and writing down the remainder after each division. In the last step, 1,2 = 0 with a remainder 1. In other words 2 is not contained in 1; so write 0 with a remainder of 1. The remainders taken in reverse order (from the bottom up) give the answer which 1001. Let us convert decimal 25 to its binary equivalent using the double dabble method. 25/2 = 12 with a remainder of 1 12/2 = 6 with a remainder of 0 6/2 = 3 with a remainder of 0 3/2 = 1 with a remainder of 1 1/2 = 0 with a remainder of 1 The numbers taken in reverse order (from the bottom to up) give the binary equivalent, which is 11001. The foregoing process can be the simplified by writing the numbers in the following diagrammatic way: 2 25 12 6 3 1 0

1 0 0 1 1

In other words, starting at the top, divide 25 by 2 and write 12 with a remainder of 1. Then divide 1 2 by 2 and write 6 with a remainder of 0 and so on. In the decimal system a fraction is separated from the whole number by a decimal point. For example 26.725 means TENS 01 2 UNITS 100 6 . Decimal point i.e. 0.725 (7 x 10-1) + (2 XX 10 2) + -(5 x 10-3) TENTHS 10-1 7 HUNDREDTHS 10-2 2 THOUSANDTH S 10-3 5

Just as there, is a decimal point in the decimal system, there is a binary point in the binary system. 22 21 20 2-1 2-2 2-3 2-4

Binary Point, i.e., 0.1101 (1x 2-1)+(1, x 2-2) + (0 x 2-3) + (1 x 2-4

Conversion of Decimal Fractions to Binary Fractions: (a) For simple fractions inspections of the above table is sufficient. eg., 0.375 = 0.25 + 0.125 = 2-2 + 2-3 Therefore, the binary equivalent is 0.011. (b) For more complicated functions it is useful to refer to the general expression for a binary equivalent function. This is d12-1 + d22-2 + d32-3 . +d(n-1)2 -(n-1) + dn2n

Therefore, continual multiplication by 2 of the part beyond the decimal point systematically isolated each term.

For example : Find Binary equivalent of 0.4375. 0.4375 x 0.875 x 0.75 x 0.5 x 2 2 2 2 = = = = 0 1 1 1 .875 .75 .5 .0

Binary equivalent of (0.4375)10 = (0.0111)2 More often than not the fraction will not work out exactly and it must be rounded off to convenient number of 'binary places/ e.g. find binary equivalent of 0.2 0.2 0.4 0.8 0.6 0.2 0.4 0.8 x x x x x x x 2 2 2 2 2 2 2 = = = = = = = 0 0 1 1 0 0 1 .4 .8 .6 .2 .4 .8 .6

Thus, binary equivalent of (0.2)10 = (.0011001)2

To round off a binary fraction to a number of places, the following binary place digit must be examined, and if it is one, this is added to the last place, but if it is zero no addition is made, i.e. rounding off the above to four places would give 0.0011. Rounding off the above to 3 places would give 0.010. Octal Number System : Conversion of Binary to Octal Besides the binary and decimal number systems, the octal number system is also useful in the computer industry. Here is a simple trick for converting a binary number to an octal number. Simply group the binary digits into groups of three, starting at the octal point, and read each set of three binary digits according to the table shown. Three Binary Digits. 000 001 010 011 100 101 110 111 Octal Digits 0 1 2 3 4 5 6 7

Let us convert the binary number 010111. First we break into threes (thus 010, 111) and then, converting each group of three binary digits, we get 27 octal. Therefore, 010 111 binary = 27 Octal.

Here are some examples : (110 010 111 001)2 (011 000 100 010)2 (6271)8 (3042)8

(101011.11)2 (53.6)8 (1101.111)2 (15.7)8

Conversion of Octal into Binary : Because base 8 of octal numbers is the third power of 2, (the base of binary numbers), the conversion from octal to binary becomes very simple. We merely convert one octal digit at a time to its binary equivalent, we proceed as follows 3 011 101 5

We have converted each octal digit into the binary equivalent (3 becomes 011 and 5 becomes 101). Therefore binary equivalent of octal 35 is 11101. Sometimes, the space is left between

each group of 3 bits, this makes it easier to read the binary number. Here are some more examples: 1 3 5 001 011 101 Thus 13578 = 001 011 101 1112 22468 = 010 010 100 1102 27.38 = 010 111. 0112 13.68 = 001 011. 1102 Hexadecimal Number System : Conversion of Binary to Hexadecimal As all hexadecimal digits can be expressed as four digit binary numbers, simply group the binary digits into groups of four starting at the hexadecimal point and read, each set of four binary digits according to the table shown: Four Binary Digits,. Hexadecimal Digits.

0000 0 0031 1 0010 2 0011 3 0100 4 0,101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F As an example, let us convert the binary number 11001101011 into hexadecimal number. First we break into four bit groups starting from the radix point (e.g., 0110, 0110, 1011). Then with the help of above table, the groups will be converted into hexadecimal digits (e.g., 66B). So 11001101011 = 66B. Here are some more examples (10100010110001)228B1 (110010101.01001)2 0001 (1 (1111100100.0111110111)2 1001 0101 . 0100 1000 9 5 4 8)16 0011 1110 0100 . 0111 1101 1100 (3 E 4. 7 D C) 16

Conversion of Hexadecimal into Binary : Since the base 16 of hexadecimal is the fourth power of 2 (the base of binary numbers), the conversion from hexadecimal to binary becomes very simple. We may merely concern one hexadecimal digit at a time to its binary equivalent. For example:

E 7 1110 0111 Thus E7.A8 16 1010

A 1010 = 1110

8 100.0 . 0111 . 1010 1000

Some more examples will make it abundantly clear 267.3D 16 = 0010 0110 0111 . 0011 1101 16

or simply, 10C1100111.0011 1101 16 3E6.E2 16 0011 1110 0110 . 1110 0010 16

or simply, 1111100110. 11100010 16 1F3.0A 0001 1111 0011 0100. 0000 1010 16

or simply,

1111100110100. 00001010 16

We have seen in the preceding paragraphs, that any number in any system can be converted into its equivalent number in any other system. Sometimes it becomes very convenient to do the conversion through an intermediate system which though seems unnecessary, facilitates the conversion very easily. For example, to convert (3E6.B7)16 to octal number. We convert it first into binary and then to octal. Thus, (3E6.B7)16 = (0011 1110 0110 . 1011 0111)2 . 101 101 110)2

(001 111 100 110 (1746.556)8

ARITHMETIC OPERATIONS: Addition, subtraction, multiplication and division in the decimal system are operations with which most people are familiar. Therefore, in order to clarify the various procedures, each basic decimal operation will be analysed and then followed by the same operation in binary. If the addition of two digits in any number system is equal or greater than the radix number, the result is a number composed of two parts, a sum and a carry digit, the carry digit being placed in the next higher column. e.g., 7 + 8 = 15, carry 1 into the next higher column. TENS UNITS 7

+ 8 -----------------------------SUM 0 5 -----------------------------CARRY 1 0 TOTAL = SUM + CARRY = 5+ 10

= =

5 10

If there has been any digits in the "tens" these would have produced a sum in the tens column to which carry digit would be added. Binary Addition In binary addition, the following are the basic rules Cases I ,, II ,, III ,, IV 0 0 1 1 + + + + 0 1 0 1 = = = = 0 1 1 10

Thus last case differs from the normal representation for decimal numbers, but it can be seen to be true because 10 in the binary code is the same as 2 in the decimal code. It can also be represented as 1 + 1 gives you the sum = 0 and carry of : 1 : Addition of larger binary numbers involves repetition by the same principles; e.g., add 10 to 10 as follows:10 + 10 -----100 0 + 0 in units column = 0 in the second column 1 + 1 = 0 with a carry of 1 Similarly, addition of three numbers would involve addition by pairs, for example 1 + 1 + 1 = 11 Some more examples are given below: 21 20 -----------------------1 1 ----------------------Sum 0 ----------------------carry 1 ----------------------Total 1 0 ------------------------

i.e., 1 + 1 = 10. This can also be seen from the decimal 1 + 1 = 2 and the binary equivalent of 2 is 10. Example: Add binary number 110110 and 101010 Binary Decimal 110 110 44 + 101 010 52 -------------------------1100 000 96 ------------------------Binary subtraction The rules for binary subtraction cover the following cases Cases ,, ,, ,, 1 2 3 4 c 1 1 10 0 0 1 1 = = = = 0 1 0 1

Basically, to subtract one counts backwards from the original. Thus to subtract 3 from 5 one counts back three digits from 5 and arrive at the answer 2. When a digit is greater than the digit which it is to be subtracted from, it is necessary to borrow from the next higher column. Example : Subtract 38 from 62 TENS UNITS 6 2 3 8 -------------2 4 --------------

Answer m (24)10

Example : Subtract binary number 11 from 110. 22 21 20 ------------------------------1 1 0 0 1 1 --------------------------------0 1 1

Answer (11) 2

Subtraction by addition :(Method of Complements) (i) 2's complement. 2's complement of 1101 is 0011 Example : Subtract 1101 from 1111 1111 2's complement of 1101 is 0011 Add this is 1111. This gives a sum of 0010 and a carry1. i.e. 1111

0011 ------0010

Ignoring carry the answer is 10

(ii) 1's complement 1's complement of 1101 is 0010. 1s complement of 1111 is 0000 Let us take the same example by l's complement method. Example : Subtract 1101 from 1's complement of 1101 is 1111

0010. Then by adding this 1111 0010 -----------------0001 1 + Again add the carry bit to the 0010 which is equal to (10)2 sum is The Answer is 10. Multiplication:

0001 + 1 ------0010

Multiplication in the binary system is extremely simple since there are only four possible combinations of digits. i.e., 0X0= 0X1= 1X0= 1X1= 0 0 0 1

Example Multiply 1101 x 101 26 25 24 23 1 1 0 0 0 22 1 1 1 0 1 0 21 0 0 0 0 0 20 1 1 1 1

Ans

1 1

1 0

When multiplying numbers which have fractions the simplest way is to remove the binary points, as is done in decimal system and then counting the number of positions they have to be moved, do the multiplication in the normal way, and finally reinsert the binary point by counting back the total number of positions previously moved. Example: Multiply 1101.11 and 1.011 To remove binary point from first number, it must be moved two places. To remove binary number from second number, it must be moved three places.

Therefore, total number of places moved is 5. Doing the multiplication in usual way gives 10010.11101 1 1 0 0 1 1 1 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 X

1 0

0 1 0

1 10010.11101 Ans.

Counting back 5 places to reinsert binary point gives 1101.11 x 1.011 =

Division: In the binary system the same method on division applies as in the decimal system. e.g. 100011 / 101 The answer would be 111 101 into 1000 goes once, remainder 11 Bringing down the next digit, 1, gives 111 101 goes into 111 once, remainder 10 Bringing down then the digit, 1, gives 101. 101 goes into 101 once, remainder zero. e.g. 1000011 / 101 111 -----101 100011 - 101 ----------------00111 - 101 --------0101 - 101 ---------000 Positive and Negative Numbers: Introduction: Considering only binary numbers, it is necessary to indicate the sign, either + or -, or a number in a manner which is acceptable to the computer. The sign of the number is denoted by the left hand bit (the most significant digit), and is now called a SIGNED BINARY NUMBER. The 0 and 1 are usually chosen to represent the positive and negative signs respectively. There are three methods that can be used to represent a signed number. i) ii) Signed magnitude. Signed 2's complement representation

iii)

Signed l's complement representation

We will consider the signed magnitude and signed-2's complement in more detail. Signed Magnitude: A separate digit position is used to indicate the sign of the number. To indicate the sign of (3) 10 which in its binary form is 011. + (3)10 is written as 011, and - (3)1o is written as 111. It is emphasised that the sign bit can not be used in the numerical part of the number, it is used exclusively for sign indication. Hence, a seven bit binary machine working in this system can only accommodate 2 7-1 = 26 = 64. numbers. Example: Represent the following number in a 7-bit machine: a) a) b) +(26)10 b) -(26)10 Six bit true binary equivalent = 011010 sign bit = 0 Hence, seven bit binary number = 0011010 Six bit true binary equivalent = 011010 sign bit 1 Hence, seven bit binary number = 1011010.

The signed magnitude method is best suited to the operations of multiplication and division and complicates the operations of addition and subtract. The signed 2's or 1's complement method is best suited for the addition and subtractions as here the sign digits can be treated as an integral part of the number itself. Signed 2s complement Representation:

You might also like