Dyadic rational (source code)

= Dyadic rational
{wiki}

A <dyadic rational> is a <rational number> of the form $m/2^k$ with an <integer> $m$ and a <nonnegative integer> $k$. Examples are $3/8$, $-5/2$, zero and every <integer>. In lowest terms, its <denominator> is a <power of two>, so its magnitude has a finite <binary expansion>.

A positive <dyadic rational> also has a binary representation ending in infinitely many ones. Replacing the last nonzero <binary digit> by zero and filling all lower places with ones preserves the value, because
$$
\sum_{j=k+1}^{\infty}2^{-j}=2^{-k}.
$$
For example, $0.101_2=0.100111\ldots_2=5/8$. Zero has no second nonnegative expansion of this type. The same ambiguity applies to the magnitude of a negative <dyadic rational>, with its sign kept separately.