# What is the standardized way to represent $\pi$ in binary notation?

How do I best represent the number $$\pi$$ in binary?

I have been thinking about it for sometime and, if it was me, I would use four bits for each digit, because four bits are sufficient to represent 10-based digits. Something like:

0011 , 0001 0100 0001 ...


I wouldn't know, also, how to represent the decimal point here.

I hope my question is clear enough.

# Update

I will put this into context. I didn't want to, because I thought you would find it stupid.

I want to make a full back tattoo, representing pi in binary so, what I am looking for is a way that will be more or less simple to scale, as I will want thousands of digits, and I want it to be precise.

• Pray tell me, how do you represent 8 and 9 with 3 bits? I would just write $\pi$ in base 2: $\pi=11.0010\ldots=2+1+2^{-3}+\cdots$ – Jyrki Lahtonen Apr 23 '12 at 10:18
• @André: What you are doing is not a genuine binary representation of $\pi$. You are just taking the decimal representation and then encoding every digit into binary. I don't know what you want to do with that. Might be exactly what you need for your purposes, but it's not a binary representation of $\pi$. What Jyrki is showing is the true binary representation of $\pi$. – Raskolnikov Apr 23 '12 at 10:26
• In base 2 $5=101_2$ because $5=1\cdot2^2+0\cdot2^1+1\cdot2^0$. Notice how the exponents indicate the position of the bit. We just continue with negative exponents. For example, $$1011.11_2=2^3+2^1+2^0+2^{-1}+2^{-2}=11\frac34.$$ – Jyrki Lahtonen Apr 23 '12 at 10:30
• About the decimal point (which I guess you could call the 'binary point' in base 2): as you can see from the comments and answers, we just represent it the same, and it marks the transition point from non-negative powers of $n$ to negative powers of $n$, for a number written in base $n$. – Tara B Apr 23 '12 at 10:43
• @J.M. Why have you removed the (binary) tag? The word binary currently occurs 17 times in the title, the question body, both answers and several comments. If someone searches for (binary)-related questions they may be interested in this one. – Peter Phipps Apr 23 '12 at 19:48

What you're suggesting is known as binary coded decimal representation. It is used by some simple calculators, and used to be commonly used in financial computing, because it can represent dollar amounts without rounding the cents (and also makes it easier to produce decimal output for human consumption). But it is harder to calculate with than true binary representation, which for $\pi$ is

11.0010010000111111011010101000100010000101101000110...


as found here. Here each bit after the point represents successively $1/2$, $1/4$, $1/8$, $1/16$, ..., $2^{-n}$, ..., so according to this representation $$\pi = 2+1+1/8+1/64+1/2048+1/4096+\cdots$$

In practical computing, irrational numbers are nowadays almost always represented in binary, rounded to a fixed number of significant binary digits and then represented in a binary variant of scientific notation. There's a widely-used standard for how to do this, IEEE-754, which allows different programs or systems to exchange floating-point values without first converting them to decimal notation. (A recent update of the standard defines more format, but is not as widely adopted).

• thank you. can you please see my update in the question? – André Alçada Padez Apr 23 '12 at 10:59
• The link Henning included in his answer (the one that says 'here') should give you all the digits you could want! – Tara B Apr 23 '12 at 11:01
• @André: The link marked "here" gives you 32768 bits. There are probably millions more to find if you google for them. – hmakholm left over Monica Apr 23 '12 at 11:02
• thank you, that is really what i was looking for – André Alçada Padez Apr 23 '12 at 11:05
• @André: Well, funnily enough that page is the first result when I google 'pi in binary'. Did you not think of trying that? – Tara B Apr 23 '12 at 11:10

Representing any real number in binary (or any base) is just the same principle as representing numbers in decimal.

For example, in decimal $\frac{25}{8} = 3.125 = 3\cdot 10^0 + 1\cdot 10^{-1} + 2\cdot 10^{-2} + 5\cdot 10^{-3}$.

Now to write the same number in binary, first express it as a sum of powers of $2$ (this is exactly what you do when writing natural numbers in binary):

$\frac{25}{8} = 2 + 1 + \frac{1}{8} = 2\cdot 2^1 + 1\cdot 2^0 + 0\cdot 2^{-1} + 0\cdot 2^{-2} + 1\cdot 2^{-3} = 11.001_2.$

• Sorry about the typos. I had a different example at first but then decided to keep it really simple, but then didn't change everything. – Tara B Apr 23 '12 at 10:38
• thank you. can you please see my update in the question? – André Alçada Padez Apr 23 '12 at 10:59

Any series of bytes can be represented in binary. You might as well encode Pi in bytes first, and then represent those bytes in binary.

If you use a "pure" binary format like described above, you'd need to write "," which is not a valid binary digit.

File formats (series of bytes) are standardized unlike ad-hoc improvisations of binary encoding.

So what I'd suggest is: get hold of the B-file (a standardized format) of OEIS A000796 (B-file available here). Now you have your bytes. Now convert the bytes into an ASCII representation of binary digits.

Python 3:

>>> import urllib.request

Beware that the generated string (from bin) will start 0b.