We use currency conversion rates for financial calculations. Our currency conversion table stores conversion rates to and from each currency (about 150 world currencies) for each day, going back 20 years. The table has millions of rows. Each conversion rate is stored with 4 decimal places (e.g. USD to EUR $1.5105$).
I was wondering if it's possible to only store rates from other currencies to USD with increased precision and then divide rates for other currencies. For example, if the rate for USD to EUR is $1.5105$ and the rate for USD to Pound is $2.2324$, then the rate from Pound to Euro would be $1.5101 / 2.2324$.
If I want the result of division to have 4 significant decimal places, unaffected by rounding, how many decimal places should dividend and divisor have?
Thanks.
"Significant places" is often shorthand for an approximate error bound. The worst case is if you want to represent $9999$ within $1$, which is a fractional error of $10^{-4}$. You are then asking what fractional error is allowable on $a$ and $b$ if you want the fractional error on $\frac ab$ to be less than $10^{-4}$. Since the numbers are small, and we want fractional errors, it is useful to take the logarithm: $\log \frac ab=\log a - \log b$, then take the derivative $\frac {\Delta \frac ab}{\frac ab}=\frac {\Delta a}a-\frac {\Delta b}b$. Roughly, this shows the fractional error in $\frac ab$ might be as high as twice the fractional error in $a$ and $b$ (if they are in opposite directions). If you are storing in decimal and only store five places, you could have still an error of one part in $10^4$ if the number you store is $10000$, but storing six places is safe.