# Fractional part

The fractional part of a non‐negative real number $x$ is the excess beyond that number integer part: $\operatorname{frac} (x)=x - \lfloor x \rfloor,\; x > 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}$

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.

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.

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.