# algorithm for correctly rounded floating point radix conversion

Is there any generic algorithm which implements a floating point radix conversion?

Lets say we have a $$p$$-digit FP number

$$A = \sum_{i=0}^{p-1} A_i \beta^{e-i}$$

in radix $$\beta$$ and with $$0 \leq A_i < \beta$$.

How do we find the $$A'_i$$, $$e'$$ values for the $$p'$$-digit base $$\gamma$$ FP number

$$A' = \sum_{i=0}^{p'-1} A'_i \gamma^{e'-i}$$

closest to $$A$$?

Also is an intermediate arbitrary precision FP calculation really necessary? (as in the function strtod in David Gay's dtoa.c)
• Except $A$ and $A'$, do all other variables taking integer values only? Are $p'$ and $\gamma$ given? – John L. Nov 20 '18 at 12:22
In the worst case, you may need very high precision intermediate results. If your problem is limited, for example p ≤ 50 and e ≤ 1,000, it will be possible to prove how much precision is needed at most - with $$1000 \cdot 10^{50}$$ possible values to convert, 200 bits precision are likely enough.