Base Conversion (2)
Radix Divide Method
- Used to convert the integer in base A to the equivalent base B integer.
- Underlying theory:
- (NI)A = bn-1Bn-1 + … + b0B0 (1.4)
Here, bi’s represents the digits of (NI)B in base A.
- NI / B = (bn-1Bn-1 + … + b1B1 + b0B0 ) / B
= (Quotient Q1: bn-1Bn-2 + … + b1B0 ) + (Remainder R0: b0)
- In general, (bi)A is the remainder Ri when Qi is divided by (B)A.
- Conversion Procedure
1. Divide (NI)B by (B)A, producing Q1 and R0. R0 is the least significant digit, d0, of the result.
2. Compute di, for i = 1 … n - 1, by dividing Qi by (B)A, producing Qi+1 and Ri, which represents di.
3. Stop when Qi+1 = 0.