# How to understand or derive the formula “Mantissa bits${}/\log_2 10 ={}$ Decimal digits of precision”?

I asked a question a couple days ago about floating point precision on stackoverflow called, "Is floating point precision mutable or invariant?" and I received the following response.

The formula is mantissa_bits / log_2 10 where the log base two of ten is 3.321928095.

I'm trying to understand why this simple formula works. I tried to derive it, but I'm failing miserably. I searched for ways logarithm can be used to compare number systems with a different base, and the best I could find was this change of base formula.

$$\log_b (x) = \frac {\log_d (x)} {\log_d (b)}$$

But substituting this formula for $$\log_2 (10)$$ in the former equation above didn't help me much. I think I may be lacking an understanding of what the variable mantissa_bits represents, or my understanding of logarithm in general. As far as I know, mantissa_bits is just a value in base $$2$$, and

$$\log_b (x) = y$$

is just

$$b^y = x$$

Will someone explain and/or derive this formula for me in a way I can understand?

This formula makes more sense when you write it like this.

$$\log_{10} (2^{24}) \approx 7.225$$

or

$${10}^{7.224719896} \approx 2^{24}$$

What this is doing is asking how many decimal digits I can multiply together to get $$2^{24}$$ or $$16\text{’}777,216$$ possible values of $$24$$ binary digits.

If you wanted to do this in reverse, it would look like this.

$$\log_2 ({10}^{7.224719896}) \approx 24$$

or

$$2^{24} \approx {10}^{7.224719896}$$

This way is asking how many binary digits I can multiply together to get $${10}^{7.224719896}$$ or $$16\text{’}777,216$$ possible values of about $$7.225$$ decimal digits.

The key variable that remains invariant is the number of possible values our number can have. Also known as permutations. More specifically, a permutation where repetition is allowed. This is represented by the following formula.

$$n \times n \times \ldots$$ ($$r$$ times) $${}= n^r$$

Therefore, the former formula in the most general case would look like this.

$$\log_\text{(base_to_convert_to)} (\text{permutations_of_number}) \approx \text{number_of_digits_of_base_to_convert_to}$$

By using this formula, you can convert the number of digits from any base number system to any other base number system while keeping the number of possible permutations constant. Thus, maintaining base precision. However, there may be a loss/gain of significance depending on the magnitude and range of the floating point number.