# How can I generate the binary representation of any real number?

In p. 30 of Baby Rudin, I find a reference to the fact that the binary representation of a real number implies the uncountablity of the set of real numbers. But I have two questions:

1. Does every real number have a binary representation? If yes, how do I prove it?
2. How can I generate the binary representation of a given real number $a$?

I'm aware of the binary representation of integers, but had never thought of a binary representation of real numbers earlier.

• Are you aware of the decimal representation of real numbers? – user856 Jul 31 '12 at 10:05
• Yes, I read this up: en.wikipedia.org/wiki/Decimal_representation – user31029 Jul 31 '12 at 10:19
• For 1: why does every real number have a decimal representation? Same goes for any other integer base $> 1$. – J. M. isn't a mathematician Jul 31 '12 at 10:20
• Thanks.I realized that after I made my comment.I had not read that wikipedia article till Rahul Narain asked my that question. – user31029 Jul 31 '12 at 10:22

Every real number $\alpha>0$ (to make things simpler) can be developed into an infinite binary expansion of the form $$110\ldots10\,.\,1011101\ldots\ ,$$ where to the left of the "decimal" point we only have finitely many digits and to the right an unending sequence of digits. Numbers of the form $n/2^N$ $\ (n, N\in{\mathbb N}_{\geq0})$ have exactly two such representations (this is the $0.999\ldots=1.000\ldots$ phenomenon in decimal), all other numbers have exactly one representation. In fact it is possible to construct the full real number system (with addition, multiplication and order) as such an "uncountable list" of binary fractions. This has been sketched by Gowers here: http://www.dpmms.cam.ac.uk/~wtg10/decimals.html

A real number $\alpha>0$ can be considered as "given" when for each $N$ it is possible to name an integer $a_N$ such that $${a_N\over 2^N}\leq \alpha<{a_N+1\over 2^N}\ .$$ Using induction one easily proves that $$2 a_N\leq a_{N+1}\leq 2a_N+1\ ,$$ and this implies that the finite binary representation of $a_{N+1}$ is obtained from the representation of $a_N$ by appending a $0$ or a $1$. Now the quotients $a_N/2^N$ approximate the given number $\alpha$. Writing $a_N$ in binary and separating the last $N$ digits by a "decimal" point we therefore get a finite binary approximation of $\alpha$, and things work out such that for $N'>N$ the first $N$ places (after the "decimal" point) of $a_N$ and $a_{N'}$ coincide. In this way we get an ever better approximation of $\alpha$ just by adding new "binary places" to the right.

When I say $\pi = 3.14\ldots$ in decimal, what does that mean? In principle, what it really means is that $\pi$ times a hundred is at least the integer three hundred and fourteen, and is less than three hundred and fifteen. And since I already know how to write the decimal representation of an integer, I can write down $314$ and then shift the point two places up to get $3.14$. So the first few digits of the decimal representation of $\pi$ are $3.14$. If I want more digits, I multiply $\pi$ by a bigger power of the base, in this case ten, and compare that result with the integers.

The binary representation is exactly the same thing, except with powers of two instead of powers of ten. For example, $\pi$ times eight is a little over twenty-five (which is $11001$ in binary), so the binary representation of $\pi$ goes $11.001\ldots$.

• Ah I get it now ... – BlueTrin Jul 31 '12 at 10:55

Yes, every real number has a binary representation, just like every real number has a decimal (and an octal, and hexadecimal, and similar for any other base) representation, though only if you allow an infinite number of digits.

There may be a cleverer way to prove it, but I'd suggest this:

1. Let x be a real number. If x a rational, we're done, so assume x is an irrational real.
2. Let epsilon greater than zero be given. Show that you can find a rational number q such that the difference between q and x is less than epsilon.
3. Thus you can approximate x to an arbitrary degree of accuracy by taking more digits.
4. The limit as epsilon goes to zero, is your representation.

Of course, if you don't allow an infinite number of digits then no irrational number has a binary (or decimal, or hexadecimal...) representation.

(I assumed that you mean computing representation by binary, Rahul Narain has a better answer if it is not the case)

I am not sure this is a mathematics question but feel free to read this:

http://en.wikipedia.org/wiki/Double-precision_floating-point_format

This is the most common representation of an approximation of a real number in computing. It is important that you know that not all numbers can be represented in most of the type and in computing these types are approximations.

Do not confuse binary with computing representation. You could create your own binary type which could theoretically store a number with an infinite number of digits with infinite memory but in the real-world, not only you have memory limitations but the common used types are standardised.

• This question is a mathematics question, but this answer is not a mathematics answer. – user856 Jul 31 '12 at 10:27