# Non-integer base of numeration

Part of a series on :
Numeral systems :
Place-value notation
Hindu–Arabic numerals
Western Arabic
Eastern Arabic
Bengali
Devanagari
Gujarati
Gurmukhi
Odia
Sinhala
Tamil
Malayalam
Telugu
Kannada
Dzongkha
Tibetan
Balinese
Burmese
Javanese
Khmer
Lao
Mongolian
Sundanese
Thai
East Asian systems
Contemporary
Chinese
Hokkien
Suzhou
Japanese
Korean
Vietnamese
Historic
Counting rods
Tangut
Other systems
History
Ancient
Babylonian
Post-classical
Cistercian
Mayan
Muisca
Pentadic
Quipu
Rumi
Contemporary
Cherokee
Kaktovik (Iñupiaq)
By radix/base
Common radices/bases
2
3
4
5
6
8
10
12
16
20
60
Non-standard radices/bases
Bijective (1)
Signed-digit (balanced ternary)
Mixed (factorial)
Negative
Complex (2i)
Non-integer (φ)
Asymmetric :
Sign-value notation
Non-alphabetic
Aegean
Attic
Aztec
Brahmi
Chuvash
Egyptian
Etruscan
Kharosthi
Prehistoric counting
Proto-cuneiform
Roman
Tally marks
Alphabetic
Abjad
Armenian
Alphasyllabic
Akṣarapallī
Āryabhaṭa
Kaṭapayādi
Coptic
Cyrillic
Geʽez
Georgian
Glagolitic
Greek
Hebrew :
List of numeral systems :
vte :
A non-integer representation uses non-integer numbers as the radix, or base, of a positional numeral system. For a non-integer radix β > 1, the value of
    $x=d_{n}\dots d_{2}d_{1}d_{0}.d_{-1}d_{-2}\dots d_{-m}$
is
    ${\begin{aligned}x&=\beta ^{n}d_{n}+\cdots +\beta ^{2}d_{2}+\beta d_{1}+d_{0}\\&\qquad +\beta ^{-1}d_{-1}+\beta ^{-2}d_{-2}+\cdots +\beta ^{-m}d_{-m}.\end{aligned}}$
The numbers d$_i$ are non-negative integers less than β. This is also known as a β-expansion, a notion introduced by Rényi (1957) and first studied in detail by Parry (1960). Every real number has at least one (possibly infinite) β-expansion. The set of all β-expansions that have a finite representation is a subset of the ring Z[β, β$^{−1}$].
There are applications of β-expansions in coding theory and models of quasicrystals.

## Construction

β-expansions are a generalization of decimal expansions. While infinite decimal expansions are not unique (for example, 1.000... = 0.999...), all finite decimal expansions are unique. However, even finite β-expansions are not necessarily unique, for example φ + 1 = φ$^2$ for β = φ, the golden ratio. A canonical choice for the β-expansion of a given real number can be determined by the following greedy algorithm, essentially due to Rényi (1957) and formulated as given here by Frougny (1992).
Let β > 1 be the base and x a non-negative real number. Denote by ⌊x⌋ the floor function of x (that is, the greatest integer less than or equal to x) and let {x} = x − ⌊x⌋ be the fractional part of x. There exists an integer k such that β$^k$ ≤ x < β$^{k+1}$. Set
    $d_{k}=\lfloor x/\beta ^{k}\rfloor$
and
    $r_{k}=\{x/\beta ^{k}\}.\,$
For k − 1 ≥  j > −∞, put
    $d_{j}=\lfloor \beta r_{j+1}\rfloor ,\quad r_{j}=\{\beta r_{j+1}\}.$
In other words, the canonical β-expansion of x is defined by choosing the largest d$_k$ such that β$^k$d$_k$ ≤ x, then choosing the largest d$_{k−1}$ such that β$^k$d$_k$ + β$^{k−1}$d$_{k−1}$ ≤ x, and so on. Thus it chooses the lexicographically largest string representing x.
With an integer base, this defines the usual radix expansion for the number x. This construction extends the usual algorithm to possibly non-integer values of β.

### Conversion

Following the steps above, we can create a β-expansion for a real number $n\geq 0$ (the steps are identical for an $n<0$, although n must first be multiplied by −1 to make it positive, then the result must be multiplied by −1 to make it negative again).
First, we must define our k value (the exponent of the nearest power of β greater than n, as well as the amount of digits in $\lfloor n_{\beta }\rfloor$, where $n_{\beta }$ is n written in base β). The k value for n and β can be written as:
    $k=\lfloor \log _{\beta }(n)\rfloor +1$
After a k value is found, $n_{\beta }$ can be written as d, where
    $d_{j}=\lfloor (n/\beta ^{j}){\bmod {\beta }}\rfloor ,\quad n=n-d_{j}*\beta ^{j}$
for k − 1 ≥  j > −∞. The first k values of d appear to the left of the decimal place.
This can also be written in the following pseudocode:
Note that the above code is only valid for $1<\beta \leq 10$ and $n\geq 0$, as it does not convert each digits to their correct symbols or correct negative numbers. For example, if a digit's value is 10, it will be represented as 10 instead of A.

### Example implementation code
#### To base π

* JavaScript:function toBasePI(num, precision = 8) { let k = Math.floor(Math.log(num)/Math.log(Math.PI)) + 1; if (k < 0) k = 0; let digits =; for (let i = k-1; i > (-1*precision)-1; i--) { let digit = Math.floor((num / Math.pow(Math.PI, i)) % Math.PI); num -= digit * Math.pow(Math.PI, i); digits.push(digit); if (num < 0.1**(precision+1) && i <= 0) break; } if (digits.length > k) digits.splice(k, 0, "."); return digits.join(""); }

#### From base π

* JavaScript:function fromBasePI(num) { let numberSplit = num.split(/\./g); let numberLength = numberSplit[0].length; let output = 0; let digits = numberSplit.join(""); for (let i = 0; i < digits.length; i++) { output += digits[i] * Math.pow(Math.PI, numberLength-i-1); } return output; }

## Examples
### Base √2

Base √2 behaves in a very similar way to base 2 as all one has to do to convert a number from binary into base √2 is put a zero digit in between every binary digit; for example, 1911$_{10}$ = 11101110111$_2$ becomes 101010001010100010101$_{√2}$ and 5118$_{10}$ = 1001111111110$_2$ becomes 1000001010101010101010100$_{√2}$. This means that every integer can be expressed in base √2 without the need of a decimal point. The base can also be used to show the relationship between the side of a square to its diagonal as a square with a side length of 1$_{√2}$ will have a diagonal of 10$_{√2}$ and a square with a side length of 10$_{√2}$ will have a diagonal of 100$_{√2}$. Another use of the base is to show the silver ratio as its representation in base √2 is simply 11$_{√2}$. In addition, the area of a regular octagon with side length 1$_{√2}$ is 1100$_{√2}$, the area of a regular octagon with side length 10$_{√2}$ is 110000$_{√2}$, the area of a regular octagon with side length 100$_{√2}$ is 11000000$_{√2}$, etc...

### Golden base

In the golden base, some numbers have more than one decimal base equivalent: they are ambiguous. For example: 11$_φ$ = 100$_φ$.

### Base ψ

There are some numbers in base ψ that are also ambiguous. For example, 101$_ψ$ = 1000$_ψ$.

### Base e

With base e the natural logarithm behaves like the common logarithm in base 10, as ln(1$_e$) = 0, ln(10$_e$) = 1, ln(100$_e$) = 2 and ln(1000$_e$) = 3 (or more precisely the representation in base e of 3, which is of course a non-terminating number). This means that the integer part of the natural logarithm of a number in base e counts the number of digits before the separating point in that number, minus one.
The base e is the most economical choice of radix β > 1, where the radix economy is measured as the product of the radix and the length of the string of symbols needed to express a given range of values. A binary number uses only two different digits, but it needs a lot of digits for representing a number; base 10 writes shorter numbers, but it needs 10 different digits to write them. The balance between those is base e, which therefore would store numbers optimally.

### Base π

Base π can be used to more easily show the relationship between the diameter of a circle to its circumference, which corresponds to its perimeter; since circumference = diameter × π, a circle with a diameter 1$_π$ will have a circumference of 10$_π$, a circle with a diameter 10$_π$ will have a circumference of 100$_π$, etc. Furthermore, since the area = π × radius$^2$, a circle with a radius of 1$_π$ will have an area of 10$_π$, a circle with a radius of 10$_π$ will have an area of 1000$_π$ and a circle with a radius of 100$_π$ will have an area of 100000$_π$.

## Properties

In every positional number system, not all numbers be expressed uniquely. For example, in base 10, the number 1 has two representations: 1.000... and 0.999.... The set of numbers with two different representations is dense in the reals, but the question of classifying real numbers with unique β-expansions is considerably more subtle than that of integer bases.
Another problem is to classify the real numbers whose β-expansions are periodic. Let β > 1, and Q(β) be the smallest field extension of the rationals containing β. Then any real number in [0,1) having a periodic β-expansion must lie in Q(β). On the other hand, the converse need not be true. The converse does hold if β is a Pisot number, although necessary and sufficient conditions are not known.