# Fractional part

The fractional part of a non‐negative real number $x$ is the excess beyond that number's integer part: $\operatorname{frac} (x)=x - \lfloor x \rfloor,\; x > 0$. Here $\lfloor x\rfloor$ is the largest integer not greater than x, the floor of x. For a positive number written in a conventional positional numeral system (such as binary or decimal), the fractional part equals the digits appearing after the radix point. Equivalently, it equals the original number with the digits before the radix point substituted with 0.

There are various conflicting ways to extend the fractional part function to negative numbers. It is either defined as $\operatorname{frac} (x)=x-\lfloor x \rfloor$ (Graham, Knuth & Patashnik 1992), as the part of the number to the right of the radix point, $\operatorname{frac} (x)=|x|-\lfloor |x| \rfloor$ (Daintith 2004), or as the odd function:

$\operatorname{frac} (x)=\begin{cases} x - \lfloor x \rfloor & x \ge 0 \\ x - \lceil x \rceil & x < 0 \end{cases}$

Here, $\lceil x \rceil$ is the smallest integer not less than x, the ceiling of x. For example, the number −1.3 has a fractional part of 0.7 according to the first definition, 0.3 according to the second definition and −0.3 according to the third definition.

Under the first definition all real numbers can be written in the form $n+r$ where $n$ is the number to the left of the radix point, and the remaining fractional part $r$ is a nonnegative real number less than one. If $x$ is a positive rational number, then the fractional part of $x$ can be expressed in the form $p/q$, where $p$ and $q$ are integers and $0 \le p < q$. For example, if x = 1.05, then the fractional part of x is 0.05 and can be expressed as 5 / 100 = 1 / 20.

Every real number can be essentially uniquely represented as a continued fraction, namely as the sum of its integer part and the reciprocal of its fractional part which is written as the sum of its integer part and the reciprocal of its fractional part, and so on.