Computer Arithmetic

Contents

 

1.Number System and Data Representation

Computer being an electronic device works on the presence or absence of electronic signals. Computer systems do not represent numeric values using the decimal system. Instead they typically use a binary or two's complement numbering system. The base of numbering system is called ‘Radix’.

It can just recognize two states either ON or OFF and numbers are represented by using these two states i.e., ON position represents‘1’ and the OFF position represent ‘0’. Therefore, any number can be represented easily by the computer under a number system which uses these two digits i.e., ‘0’ and ‘1’. This system is called Binary system.

Decimal Number System:

In this number system we use 10 digits from 0 to 9. Each decimal ‘digit’ takes one of these ten values. The value depends on the ‘position’ of the number system i.e., units, tens, hundreds and so on. The positional value of each digit has to be the power of 10. Therefore, the Radix of decimal system is 10.

Let’s understand this with an Example: Consider a number 354

This is also represented as (354)10

354=3*102 + 5*101 + 4*100=300+50+4

Binary Number system or base-2 number system:

The binary digits (0 and 1) are used to represent data in a computer. In computer terminology, the binary digit is called as a ‘bit’. All the alphabets, numbers and symbols etc are represented in terms of 0s and 1s. The positional value of each digit has to be the power of 2. The radix of binary system is 2.So this is also called as ‘BASE2’ number system.

For converting binary to decimal, we should multiply place value of binary numbers with the number and add the result so to get the value in decimal system.

Example: Convert 101012 to its equivalent decimal.

Solution:

25 24 23 22 21 20    Place value

    1  0  1   0  1     Binary number given in the example

101012=1*24+0*23+1*22+0*21+1*20 =16+0+4+0+1=2110

Octal Number System:

In Octal number system the base is 8. Therefore, it is called as Base-8 number system. The eight symbols or digits are from 0 to 7.

Example: Convert Octal Number 2057 to decimal.

Solution:

(2057) 8= 2*83+0*82+5*81+7*80 = 1024+0+40+7=107110

Hexadecimal System:

In this number system the base is 16.Hence 16 elements are used for its representation. The first 10 digits form from 0 to 9. The remaining six digits are denoted by symbols A, B, C, D, E, and F, representing 10, 11,12,13,14 and 15, respectively. Each position in hexadecimal number system represents a power of the base (16).

Example: Convert hexadecimal number 1AF to decimal.

Solution:

(1AF) 16 = 1*162+10*161+1*160

              = (1*256) + (10*16) + (15*1) =256+160+15=43110

Converting from Decimal to another base:

Decimal to binary conversion: The given decimal number is repeatedly divided by 2 (base of binary system) until it is no longer divisible. At the end of each of successive division, the remainder is written in the next column. The binary equivalent of given decimal number is obtained by writing the remainder from the bottom to the top starting from 1.

Example: Convert decimal 156 into its equivalent binary

Solution:

2)156   Remainder

 2)78          0
 2)39          0

 2)19          1

  2)9          1
  2)4          1
  2)2          0
  2)1          0
  2)0          1

 

 Binary equivalent of 15610 = 100111002

Note: To convert Decimal to any base we should divide the decimal with that base. And the rest procedure is same as with decimal to binary conversion.

Example: Convert 42810   to hexadecimal.

Solution:

 

16)428    Remainder

16)26            12=C
16)1             10=A

16)0              1=1

 

 42810 = 1AC16

Fractional Number:

In binary number system, fractional numbers are formed similar as in decimal number system.

Example: 0.43610 = (4*10-1) + (3*10-2) + (6*10-3)

Similarly in binary number system,

0.6572 = (6*2-1) + (5*2-2) + (7*2-3)

Example: Convert Decimal equivalent of the binary number 110.101 

Solution: 110.1012 = 1*22+1*21+0*20+1*2-1+0*2-2+1*2-3

                     =4+2+0+0.5+0+0.125

               =6.625

110.101 =6.62510