Decimal representation

A decimal representation of a non-negative real number $r$ is its expression as a sequence of symbols consisting of decimal digits traditionally written with a single separator: $$r = b_k b_{k-1}\ldots b_0.a_1a_2\ldots$$ Here. is the decimal separator, $k$ is a nonnegative integer, and $$b_0, \ldots, b_k, a_1, a_2,\ldots$$ are digits, which are symbols representing integers in the range 0, ..., 9.

Commonly, $$b_k\neq 0$$ if $$k \geq 1.$$ The sequence of the $$a_i$$—the digits after the dot—is generally infinite. If it is finite, the lacking digits are assumed to be 0. If all $$a_i$$ are 0, the separator is also omitted, resulting in a finite sequence of digits, which represents a natural number.

The decimal representation represents the infinite sum: $$ r=\sum_{i=0}^k b_i 10^i + \sum_{i=1}^\infty \frac{a_i}{10^i}.$$

Every nonnegative real number has at least one such representation; it has two such representations (with $$b_k\neq 0$$ if $$k>0$$) if and only if one has a trailing infinite sequence of 0, and the other has a trailing infinite sequence of 9. For having a one-to-one correspondence between nonnegative real numbers and decimal representations, decimal representations with a trailing infinite sequence of 9 are sometimes excluded.

Integer and fractional parts
The natural number $\sum_{i=0}^k b_i 10^i$, is called the integer part of $r$, and is denoted by $a_{0}$ in the remainder of this article. The sequence of the $$a_i$$ represents the number $$0.a_1a_2\ldots = \sum_{i=1}^\infty \frac{a_i}{10^i},$$ which belongs to the interval $$[0,1),$$ and is called the fractional part of $r$ (except when all $$a_i$$ are 9).

Finite decimal approximations
Any real number can be approximated to any desired degree of accuracy by rational numbers with finite decimal representations.

Assume $$x \geq 0$$. Then for every integer $$n\geq 1$$ there is a finite decimal $$r_n=a_0.a_1a_2\cdots a_n$$ such that:

$$r_n\leq x < r_n+\frac{1}{10^n}.$$

Proof: Let $$r_n = \textstyle\frac{p}{10^n}$$, where $$p = \lfloor 10^n x\rfloor$$. Then $$p \leq 10^nx < p+1$$, and the result follows from dividing all sides by $$10^n$$. (The fact that $$r_n$$ has a finite decimal representation is easily established.)

Non-uniqueness of decimal representation and notational conventions
Some real numbers $$x$$ have two infinite decimal representations. For example, the number 1 may be equally represented by 1.000... as by 0.999... (where the infinite sequences of trailing 0's or 9's, respectively, are represented by "..."). Conventionally, the decimal representation without trailing 9's is preferred. Moreover, in the standard decimal representation of $$x$$, an infinite sequence of trailing 0's appearing after the decimal point is omitted, along with the decimal point itself if $$x$$ is an integer.

Certain procedures for constructing the decimal expansion of $$x$$ will avoid the problem of trailing 9's. For instance, the following algorithmic procedure will give the standard decimal representation:  Given $$x\geq 0$$, we first define $$a_0$$ (the integer part of $$x$$) to be the largest integer such that $$a_0\leq x$$ (i.e., $$a_0 = \lfloor x\rfloor$$). If $$x=a_0$$ the procedure terminates. Otherwise, for $(a_i)_{i=0}^{k-1}$ already found, we define $$a_k$$ inductively to be the largest integer such that:

The procedure terminates whenever $$a_k$$ is found such that equality holds in $$; otherwise, it continues indefinitely to give an infinite sequence of decimal digits. It can be shown that $x = \sup_k \left\{\sum_{i=0}^{k} \frac{a_i}{10^i}\right\}$ (conventionally written as $$x=a_0.a_1a_2a_3\cdots$$), where $$a_1,a_2,a_3\ldots \in \{0,1,2,\ldots, 9\},$$ and the nonnegative integer $$a_0$$ is represented in decimal notation. This construction is extended to $$x<0$$ by applying the above procedure to $$-x>0$$ and denoting the resultant decimal expansion by $$-a_0.a_1a_2a_3\cdots$$.

Finite
The decimal expansion of non-negative real number x will end in zeros (or in nines) if, and only if, x is a rational number whose denominator is of the form 2n5m, where m and n are non-negative integers.

Proof:

If the decimal expansion of x will end in zeros, or $x=\sum_{i=0}^n\frac{a_i}{10^i} = \sum_{i=0}^n 10^{n-i}a_i/10^n$ for some n, then the denominator of x is of the form 10n = 2n5n.

Conversely, if the denominator of x is of the form 2n5m, $$x = \frac{p}{2^n5^m}=\frac{2^m5^np}{2^{n+m}5^{n+m}} = \frac{2^m 5^np}{10^{n+m}}$$ for some p. While x is of the form $$\textstyle\frac{p}{10^k}$$, $$p = \sum_{i=0}^{n} 10^i a_i$$ for some n. By $$x=\sum_{i=0}^n10^{n-i}a_i/10^n=\sum_{i=0}^n\frac{a_i}{10^i}$$, x will end in zeros.

Repeating decimal representations
Some real numbers have decimal expansions that eventually get into loops, endlessly repeating a sequence of one or more digits:
 * $1/3$ = 0.33333...
 * $1/7$ = 0.142857142857...
 * $1318/185$ = 7.1243243243...

Every time this happens the number is still a rational number (i.e. can alternatively be represented as a ratio of an integer and a positive integer). Also the converse is true: The decimal expansion of a rational number is either finite, or endlessly repeating.

Finite decimal representations can also be seen as a special case of infinite repeating decimal representations. For example, $36/25$ = 1.44 = 1.4400000...; the endlessly repeated sequence is the one-digit sequence "0".

Non-repeating decimal representations
Other real numbers have decimal expansions that never repeat. These are precisely the irrational numbers, numbers that cannot be represented as a ratio of integers. Some well-known examples are:
 * √2 = 1.41421356237309504880...
 * &thinsp;e = 2.71828182845904523536...
 * &thinsp;π = 3.14159265358979323846...

Conversion to fraction
Every decimal representation of a rational number can be converted to a fraction by converting it into a sum of the integer, non-repeating, and repeating parts and then converting that sum to a single fraction with a common denominator.

For example, to convert $\pm 8.123\overline{4567}$ to a fraction one notes the lemma: $$ \begin{align} 0.000\overline{4567} & = 4567\times0.000\overline{0001} \\ & = 4567\times0.\overline{0001}\times\frac{1}{10^3} \\ & = 4567\times\frac{1}{9999}\times\frac{1}{10^3} \\ & = \frac{4567}{9999}\times\frac{1}{10^3} \\ & = \frac{4567}{(10^4 - 1)\times10^3}& \text{The exponents are the number of non-repeating digits after the decimal point (3) and the number of repeating digits (4).} \end{align} $$

Thus one converts as follows: $$ \begin{align} \pm 8.123\overline{4567} & = \pm \left(8 + \frac{123}{10^3} + \frac{4567}{(10^4 - 1) \times 10^3}\right) & \text{from above} \\ & = \pm \frac{8\times(10^4-1)\times10^3+123\times(10^4-1)+4567}{(10^4 - 1) \times 10^3} & \text{common denominator}\\ & = \pm \frac{81226444}{9999000} & \text{multiplying, and summing the numerator}\\ & = \pm \frac{20306611}{2499750} & \text{reducing}\\ \end{align} $$

If there are no repeating digits one assumes that there is a forever repeating 0, e.g. $$1.9 = 1.9\overline{0}$$, although since that makes the repeating term zero the sum simplifies to two terms and a simpler conversion.

For example: $$ \begin{align} \pm 8.1234 & = \pm \left(8 + \frac{1234}{10^4}\right) & \\ & = \pm \frac{8\times10^4+1234}{10^4} & \text{common denominator}\\ & = \pm \frac{81234}{10000} & \text{multiplying, and summing the numerator}\\ & = \pm \frac{40617}{5000} & \text{reducing}\\ \end{align} $$