Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

NUMBER BASES AND COMPUTER ARITHMETIC

NUMBER BASE ARITHMETIC


Numbers in the decimal system are represented by means of positional notation. That is,
the value or weight of a digit depends on its location within the number. A number N,
when expressed in positional notation in the base b, is written as:
anan-1an-2 … a1a0.a-1a-2 … a-m
and defined as
anbn + an-1bn-1 + … + a1b1 + a0b0 + a-1b-1 + a-2b-2 + … + a-mb-m
n
¿ ∑ ai bi
i=−m

The “a” in the above equation are called digits and may have one of “b” possible values.
Positional notation employs the radix point to separate the integer and fractional parts of
the number. Decimal arithmetic uses the decimal point while binary arithmetic uses
binary point.
We shall be considering four bases – decimal, binary, octal, and hexadecimal

Decimal: base, b = 10, digits, a = {0,1,2,3,4,5,6,7,8,9}


Binary: base, b = 2 digits, a ={0,1}
Octal: base, b = 8 digits, a = {0,1,2,3,4,5,6,7}
Hexadecimal: base, b = 16 digits, a = {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}

Subscript is used to indicate the base of a number when necessary, for example, 123 10,
4568, 10112.

People normally work in decimal and computers in binary. The purpose of the octal and
hexadecimal systems is as an aid to human memory since they are shorter than binary
digits. Moreover, octal and hexadecimal numbers are more compact than binary numbers
(one octal digit equals three binary digits and one hexadecimal digit equals four binary
digits), they are used in computer texts and core-dumps (printout of part of the
computer’s memory). The advantage of binary number is in decoding electrical signals
that switch on (logical one), or switch off (logical zero) a device.
a. CONVERSION OF INTEGERS FROM DECIMAL TO BINARY
To convert a decimal integer to binary, divide the number successively by 2, and after
each division record the remainder which is either 1 or 0. The process is terminated only
when the result of the division is 0 remainder 1. The result is read from the most
significant bit (the last remainder) upwards.

For example: to convert 12310 to binary, we have


Numerator Divisor Quotient Remainder
123 2 61 1
61 2 30 1
30 2 15 0
15 2 7 1
7 2 3 1
3 2 1 1
1 2 0 1
Consequently, 12310 = 11110112
b. CONVERSION OF INTEGERS FROM DECIMAL TO OCTAL
Just as in binary above except that the divisor is 8. The process of conversion ends when
the final result is 0 remainder R (where 0 ≤ R < 8).

For example: to convert 462910 to octal, we have

Numerator Divisor Quotient Remainder


4629 8 578 5
578 8 72 2
72 8 9 0
9 8 1 1
1 8 0 1
Therefore, 462910 = 110258

c. CONVERSION OF INTEGERS FROM DECIMAL TO HEXADECIMAL


Just as in binary and octal. The divisor is 16. The remainder lies in the decimal range 0
to 15, corresponding to the hexadecimal range 0 to F.
For example: to convert 5324110 to hexadecimal, we have

Numerator Divisor Quotient Remainder


53241 16 3327 9
3327 16 207 15 = F
207 16 12 15 = F
12 16 0 12 = C
Therefore, 5324110 = CFF916
d. CONVERSION OF INTEGERS FROM OTHER BASES TO DECIMAL
Just express in the positional notation earlier stated above. But take note of the base.
For example, to convert 10101112, 64378, and 1AC16 to decimal
i. 10101112 = 1 × 26 + 0 × 25 + 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 1 × 20
= 1 × 64 + 0 × 32 + 1 × 16 + 0 × 8 + 1 × 4 + 1 × 2 + 1 × 1
= 64 + 0 + 16 + 0 + 4 + 2 + 1
= 8710
ii. 64378 = 6 × 83 + 4 × 82 + 3 × 81 + 7 × 80
= 6 × 512 + 4 × 64 + 3 × 8 + 7 × 1
= 3072 + 256 + 24 + 7
= 335910
iii. 1AC16 = 1 × 162 + 10 × 161 + 12 × 160
= 1 × 256 + 10 × 16 + 12 × 1
= 256 + 160 +12
= 42810

e. CONVERSION FROM BINARY INTEGER TO OCTAL


Form the bits into groups of three starting at the binary point and moving leftwards.
Replace each group of three bits with the corresponding octal digits (0 to 7).
For example, to convert 110010111012 to Octal
110010111012 = 11 001 011 101
11 = 1 × 21 + 1 × 20 = 3; 001 = 0 × 22 + 0 × 21 + 1 × 20 = 1; 011 =0 × 22 + 1 × 21 + 1 ×
20 = 3; 101 = 1 × 22 + 0 × 21 + 1 × 20 = 5
Therefore 110010111012 = 31358

f. CONVERSION FROM BINARY INTEGER TO HEXADECIMAL


The binary number is formed into groups of four bits starting at the binary point. Each
group is replaced by a hexadecimal digit from 0 to 9, A, B, C, D, E, F.
For example, to convert 110010111012 to hexadecimal
110010111012 = 110 0101 1101
110 = 1 × 22 + 1 × 21 + 0 × 20 = 6; 0101 = 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 5;
1101 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 13 = D
Therefore 110010111012 = 65D16

g CONVERSION FROM OCTAL TO BINARY


Converting an octal number into its binary equivalent requires the reverse procedure of
converting from binary to octal. Each octal digit is simply replaced by its binary
equivalent.
For example, to convert 413578 to binary
413578 : converting each digit into binary, we have
4 = 100 1 = 001 3 = 011 5 = 101 7 = 111
Replacing each octal digit by its binary equivalent:
413578 = 100 001 011 101 111 = 1000010111011112

h. CONVERSION FROM HEXADECIMAL TO BINARY


Each hexadecimal digit is replaced by its 4-bit binary equivalent. For example, to convert
AB4C16 to binary
AB4C16: A = 10 =1010 B = 11 = 1011 4 = 0100 C = 12 =
1100
AB4C16 = 1010 1011 0100 1100 = 1010101101001100

i. CONVERSION FROM HEXADECIMAL TO OCTAL


Conversion between hexadecimal and octal values is best performed via binary. For
example, to convert 12BC16 to octal
12BC16 = 1 0010 1011 1100
Regrouping into three bits from the right-hand side
12BC16 = 1 001 010 111 100
Converting each group into octal digit
12BC16 = 112748
j. CONVERSION FROM OCTAL TO HEXADECIMAL
For example, to convert 413578 to hexadecimal
413578 = 4 =100 1 = 001 3 = 011 5 = 101 7 = 111
Regrouping into four bits
413578 = 100 0010 1110 1111
= 4 2 14 15
= 42EF16

k. CONVERSION OF BINARY FRACTIONS TO DECIMAL


Treat all fractions as integers scaled by an appropriate factor. For example, to convert
0.011012
By expressing in standard form, we have
0.011012 = 0 × 2-1 + 1 × 2-2 + 1 × 2-3 + 0 × 2-4 + 1 × 2-5
1
=0× + 1 × 1/ 22 + 1 ×1/ 23 + 0 × 1/24 + 1 × 1/25
2
1 1 1 1 1
=0 × + 1 × + 1 × + 0 × +1×
2 4 8 16 32
1 1 1 1 1 1 8+4 +1 13
=0+ + +0+ = + + = = =0.40625
4 8 32 4 8 32 32 32
∴ 0.011012 = 0.4062510

l. CONVERSION OF DECIMAL FRACTIONS TO BINARY


To convert a decimal fraction to binary fraction, the decimal fraction is multiplied by two
(2) and the integer part noted. The integer, which is either 1 or 0, is then stripped from
the number to leave a fractional part. The new fraction is multiplied by two (2) and the
integer part noted. The process is carried out repeatedly until it ends or a sufficient
degree of precision has been achieved. The binary fraction is formed by reading the
integer parts from the top to the bottom.
For example, to convert 0.687510 to binary

0.6875 × 2 = 1.3750
0.3750 × 2 = 0.7500
0.7500 × 2 = 1.5000
0.5000 × 2 = 1.0000

∴ 0.687510 = 0.10112
We can convert from decimal fractions to octal or hexadecimal fractions by using the
same algorithms used for binary conversions. We only need to change the base (that is:
2, 8, 16).

m. CONVERSION OF BINARY FRACTIONS TO OCTAL/HEXADECIMAL


Split the binary digits into groups of three (four for hexadecimal), start grouping bits at
the binary point and move to the right. Any group of digits remaining on the right
containing fewer than three (four for hexadecimal) bit must be made up to three (four for
hexadecimal) bit by the addition of zeros to the right of the least significant bit.
For example, to convert 0.101011002 and 0.101011112 to octal
0.101011002 = 0. 101 011 00(0)2 = 0.5308
0.101011112 = 0. 101 011 11(0)2 = 0.5368
To convert to hexadecimal
0.101011002 = 0. 1010 1100 = 0.AC16
0.1010110012 = 0. 1010 1100 1(000) =0.AC816
n. CONVERSION OF OCTAL/HEXADECIMAL FRACTIONS TO BINARY
0.4568 = 0. 100 101 110 = 0.1001011102
0.ABC16 = 0. 1010 1011 1100 = 0.1010101111002

You might also like