# How to convert $\pi$ to base 16?

According to this Wikipedia article $\pi$ is approximately 3.243F in base 16 (i.e. hexadecimal).

Can someone explain this? (Note: I understand how to convert an integer to base 16)

Thanks

• How to convert to base 16: In base $16$ we have (by definition) $\pi = 3 + \sum_{n=1}^\infty \frac{a_n}{16^n}$. From this it follows that $a_1 = \lfloor(\pi-3)16\rfloor$, $a_2 = \lfloor(\pi -3 - a_1/16)16^2\rfloor$, and so on Apr 12, 2015 at 19:48
• This means $\pi$ is approximately $$3+\frac{2}{16}+\frac{4}{16^2}+\frac{3}{16^3}+\frac{15}{16^4}$$ Apr 12, 2015 at 19:49
• Ohh. Got it. Thanks!
– Ben
Apr 12, 2015 at 19:49
• In case you are not only interested in converting any number to base 16, the Bailey-Borwein-Plouffe formula (to compute Pi) might be worth a look, since it works on base 16 :-) Oh - now I've seen that @azimut has told exactly this formula. Apr 13, 2015 at 7:58
• In practice you typically do it the other way round. You compute pi in binary/hex and then convert it to decimal. Apr 13, 2015 at 10:14

One way to convert any decimal fraction to base $$16$$ is as follows (taking $$\pi$$ as an example).$$\pi=\color{blue}3.141592...$$

Take the whole number part and convert it to base $$16$$ as usual. In this case $$\color{blue}3$$ will remain as $$3$$. So we have so far got $$3.14159..._{10}=\color{red}{3...._{16}}$$

This now leaves us with $$0.141592...$$ - Multiply this by our new base to get $$\color{red}{16}\times0.14159...=\color{blue}2.26544...$$Now again convert the whole number part to our new base as usual - in this case the $$\color{blue}2$$ remains as a $$2$$. So we have so far got $$3.14159..._{10}=\color{red}{3.2..._{16}}$$

This now leaves us with $$0.26544...$$ - Multiply this by our new base to get $$\color{red}{16}\times0.26544...=\color{blue}4.24704...$$Now again convert the whole number part to our new base as usual - in this case the $$\color{blue}4$$ remains as a $$4$$. So we have so far got $$3.14159..._{10}=\color{red}{3.24..._{16}}$$

This now leaves us with $$0.24704...$$ - Multiply this by our new base to get $$\color{red}{16}\times0.24704...=\color{blue}3.95264...$$Now again convert the whole number part to our new base as usual - in this case the $$\color{blue}3$$ remains as a $$3$$. So we have so far got $$3.14159..._{10}=\color{red}{3.243..._{16}}$$

You can continue this process for as many digits as you require.

Note that: $$10000\pi=31415.92653\dots$$ which means that the decimal version of $\pi$ begins $3.1415\dots$.

Similarly: $$16^4\pi=205887.46145\dots$$ Since $205887$ is $3243F$ in hexadecimal, the hexadecimal version begins $3.243F\dots$.

For the particular base of $16$, there is this remarkable formula: $$\pi=\sum_{n=0}^\infty \left(\frac{4}{8n+1}-\frac{2}{8n+4}-\frac{1}{8n+5}-\frac{1}{8n+6}\right)\frac{1}{16^n}$$ It allows the computation of any base 16 digit of $\pi$ without the need to compute all the preceding digits.

The discovery of this formula by Bailey, Borwein and Plouffe in 1995 came as a big surprise, as it was conjectured that no such formula can exist.

• weird, for $n=0$ i don't get a $3$ that is the first digit in base $16$. Is this formula correct? Apr 13, 2015 at 2:04
• @Héctor According to this source finding the nth digit is possible with this, but it is not as straighforward as plugging a certain n into this formula.
– Jos
Apr 13, 2015 at 6:45
• As @Jos already pointed the correct link, the name of this formula should be told: Bailey-Borwein-Plouffe formula. Apr 13, 2015 at 8:02
• @tueftl: ok, I've added the names and a link to the wikipedia page. Apr 13, 2015 at 9:31
• The really extraordinary of the formula BBP is the history fact that before it everybody though that the calcul of an irrational must be step by step, that was impossible to determine any digit of position n, say, whitouh determine the precedent digits. (sorry by my ugly english. Apr 13, 2015 at 12:37