The generalized division algorithm for converting decimal integers in
other bases is:
Integer. Given an integral number NI(b) it can be represented in a new base q as:
NI(b) =a′n*qn+a′n-1*qn-1+ ... + a′0*q0
where a′i are digits expressed in the base q (i=0,1,2,...,n). In order to convert the number we must determine the value of the coefficients a′i in the base q.
These coefficients are obtained by repeatedly division of the number NI(b) to the base q, as:
NI(b) / q =a′n*qn-1+a′n-1*qn-2+ ... +a′1*q0+a′0⇒ a remainder a′0(q) and a quotient
N'I(b)=a′n*qn-1+a′n-1*qn-2+...+a′1*q1-1.
By division with q we obtain a remainder a′1(q) and a new quotient. We continue the division process until we determine a′n(q) (until the quotient is 0).
The digit a′n(q) is the most significant digit of the number in the new base q and a′0(q) is the most unsignificant digit of the number in the new base q.
The generalized algorithm for this method is:
Step1. |
Divide the number to the new base and obtain a quotient and a remainder. The remainder just obtained is a digit in the new base; |
Step2. |
If the quotient is not 0
Then
take in account the quotient as a new number and execute Step1;
Else
the conversion process stops. |
The coefficients are written in reverse order they obtained and the number is the equivalent in the new base: a′n a′n-1 ... a′0(q).