Dyadic rationals in the interval from 0 to 1.

In mathematics, a dyadic rational is a number that can be expressed as a fraction whose denominator is a power of two. For example, 1/2, 3/2, and 3/8 are dyadic rationals, but 1/3 is not. These numbers are important in computer science because they are the only ones with finite binary representations; they also have applications in weights and measures and in musical time signatures.

## Arithmetic

The sum, product, or difference of any two dyadic rationals is itself another dyadic rational:

${\displaystyle {\frac {a}{2^{b}}}+{\frac {c}{2^{d}}}={\frac {2^{d-\min(b,d)}a+2^{b-\min(b,d)}c}{2^{\max(b,d)}}}}$
${\displaystyle {\frac {a}{2^{b}}}-{\frac {c}{2^{d}}}={\frac {2^{d-b}a-c}{2^{d}}}\quad (d\geq b)}$
${\displaystyle {\frac {a}{2^{b}}}-{\frac {c}{2^{d}}}={\frac {a-2^{b-d}c}{2^{b}}}\quad (d
${\displaystyle {\frac {a}{2^{b}}}\times {\frac {c}{2^{d}}}={\frac {a\times c}{2^{b+d}}}.}$
However, the result of dividing one dyadic fraction by another is not necessarily a dyadic fraction.

Because they are closed under addition, subtraction, and multiplication, but not division, the dyadic fractions are a ring but not a field. As a ring, the dyadic fractions are a subring of the rational numbers, and an overring of the integers. Algebraically, this subring is the localization of the integers with respect to the set of powers of two.

The set of all dyadic fractions is dense in the real line: any real number ${\displaystyle x}$ can be arbitrarily closely approximated by dyadic rationals of the form ${\displaystyle \left\lfloor 2^{i}x\right\rfloor /2^{i}}$. Compared to other dense subsets of the real line, such as the rational numbers, the dyadic rationals are in some sense a relatively "small" dense set, which is why they sometimes occur in proofs. (See for instance Urysohn's lemma for the dyadic rationals.)

The dyadic fractions are precisely those numbers possessing finite binary expansions. Their binary expansions are not unique; there is one finite and one infinite representation of each dyadic rational other than 0 (ignoring terminal 0s). For example, 0.12 = 0.0111...2 = 1/2. Also, 0.112 = 0.10111...2 = 3/4.

Addition modulo 1 forms a group; this is the Prüfer 2-group. (This is the same as taking the quotient group of the dyadic rationals by the integers.)

## Dual group

Considering only the addition and subtraction operations of the dyadic rationals gives them the structure of an additive abelian group. The dual group of a group consists of its characters, group homomorphisms to the multiplicative group of the complex numbers, and in the spirit of Pontryagin duality the dual group of the additive dyadic rationals can also be viewed as a topological group. It is called the dyadic solenoid and is an example of a solenoid group and of a protorus.

The dyadic rationals are the direct limit of infinite cyclic subgroups of the rational numbers,

${\displaystyle \varinjlim \left\{2^{-i}\mathbb {Z} \mid i=0,1,2,\dots \right\},}$
and their dual group can be constructed as the inverse limit of the unit circle group under the repeated map
${\displaystyle \zeta \mapsto \zeta ^{2}.}$

An element of the dyadic solenoid can be represented as an infinite sequence of complex numbers ${\displaystyle q_{0},q_{1},q_{2},\dots }$, with the properties that each ${\displaystyle q_{i}}$ lies on the unit circle and that, for all ${\displaystyle i>0}$, ${\displaystyle q_{i}^{2}=q_{i-1}}$. The group operation on these elements multiplies any two sequences componentwise. Each element of the dyadic solenoid corresponds to a character of the dyadic rationals that maps ${\displaystyle a/2^{b}}$ to the complex number ${\displaystyle q_{b}^{a}}$. Conversely, every character ${\displaystyle \chi }$ of the dyadic rationals corresponds to the element of the dyadic solenoid given by ${\displaystyle q_{i}=\chi (1/2^{i})}$.

As a topological space the dyadic solenoid is a solenoid, and an indecomposable continuum.[1]

## Related constructions

Just as the dyadic rational numbers are the numbers with finite binary representations, the terminating decimals are the numbers with finite decimal representations. The same construction can be applied in any radix. When the radix is a prime number ${\displaystyle p}$, the corresponding set of numbers are called the ${\displaystyle p}$-adic fractions or ${\displaystyle p}$-adic rationals, and share many properties and formulas with the dyadic rationals.

The surreal numbers are generated by an iterated construction principle which starts by generating all finite dyadic fractions, and then goes on to create new and strange kinds of infinite, infinitesimal and other numbers.

The binary van der Corput sequence is an equidistributed permutation of the positive dyadic rational numbers.

## Applications

### In metrology

The inch is customarily subdivided in dyadic rather than decimal fractions; similarly, the customary divisions of the gallon into half-gallons, quarts, and pints are dyadic. The ancient Egyptians also used dyadic fractions in measurement, with denominators up to 64.[2]

### In music

Time signatures in Western musical notation traditionally consist of dyadic fractions (for example: 2/2, 4/4, 6/8...), although non-dyadic time signatures have been introduced by composers in the twentieth century (for example: 2/., which would literally mean 2/​38). Non-dyadic time signatures are called irrational in musical terminology, but this usage does not correspond to the irrational numbers of mathematics, because they still consist of ratios of integers. Irrational time signatures in the mathematical sense are very rare, but one example (42/1) appears in Conlon Nancarrow's Studies for Player Piano.

### In computing

As a data type used by computers, floating-point numbers are often defined as integers multiplied by positive or negative powers of two, and thus all numbers that can be represented for instance by binary IEEE floating-point datatypes are dyadic rationals. The same is true for the majority of fixed-point datatypes, which also uses powers of two implicitly in the majority of cases.

### Topology

In general topology, dyadic fractions can be used in the proof of Urysohn's lemma, which is commonly considered one of the most important theorems in topology.