Exchange between base 10 and base 2: is there any criteria to define when the numerical representation will be finite?

84 Views Asked by At

I was doing some exercises about conversion of numerical representation between base 10 and base 2. In particular, i was solving the exercise: $(3.1416)_{10} $ to base 2. I solved about sixteen interactions over the fractional part and i wasn't expecting it to end very soon (actually i was hoping for some period to show).

So my question is: is there any criteria to decide when the numerical representation will be finite?

3

There are 3 best solutions below

0
On BEST ANSWER

The base $b$ representation of $x$ is finite if and only if $b^d x$ is an integer for some $d$. If you write $x$ as a rational number of the form $m/n$ (in lowest terms), what you need is that with $n$ divides some power of $b$.

Equivalently, every prime dividing $n$ also divides $b$. If $b = 2$, the only prime allowed is $2$: $n$ must be a power of $2$.

Now if the decimal representation of $x$ is $A.B$, i.e. the fractional part of $x$ is $B/10^d$ where $B$ consists of $d$ digits, this is equivalent to $B$ being divisible by $5^d$.

0
On

Yes. The real number $x$ can be written in base $2$ with a finite number of digits if and only if $x$ is rational and its denominator (written in smallest term) is a power of two.

For a proof, note that dividing by $2^n$ is base $2$ can be done by moving the point rightwards $n$ places, and conversely, if $x$ has $n$ digits then $2^nx$ is an integer.

0
On

A rational number written as $\frac pq$ in lowest terms, has a finite binary representation if and only if $q$ is a power of $2$.

How this works out if your original number is a decimal fraction is:

  • If the decimal representation does not end, then neither does the binary one.

  • If the decimal representation does end, then take all the digits after the decimal point and check whether the number they make up is divisible by $5^n$, where $n$ is the number of digits. The binary representation is finite exactly if $5^n$ divides the digits.

For example $1416$ is not divisible by $5^4$, so $3.1416$ does not have a finite binary fraction representation.

On the other hand $123.625$ has a finite binary fraction because $625$ is divisible by $5^3=125$.


Oh, and by the way, the period of the binary representation of $3.1416$ is exactly $500$ bits long. (Found in the boring way by writing program to do the long division $1416\div10000$ in base $2$ and check when the remainder repeated).