# Fractional part

The fractional part or decimal part of a non‐negative real number $x$ is the excess beyond that number's integer part. If the latter is defined as the largest integer not greater than x, called floor of x or $\lfloor x\rfloor$ , its fractional part can be written as:

$\operatorname {frac} (x)=x-\lfloor x\rfloor ,\;x>0$ .

For a positive number written in a conventional positional numeral system (such as binary or decimal), its fractional part hence corresponds to the digits appearing after the radix point.

## For negative numbers

However, in case of negative numbers, there are various conflicting ways to extend the fractional part function to them: It is either defined in the same way as for positive numbers, i.e. by $\operatorname {frac} (x)=x-\lfloor x\rfloor$ (Graham, Knuth & Patashnik 1992), or as the part of the number to the right of the radix point, $\operatorname {frac} (x)=|x|-\lfloor |x|\rfloor$ (Daintith 2004), finally, by the odd function.

$\operatorname {frac} (x)={\begin{cases}x-\lfloor x\rfloor &x\geq 0\\x-\lceil x\rceil &x<0\end{cases}}$ with $\lceil x\rceil$ as the smallest integer not less than x, also called the ceiling of x. By consequence, we may get, for example, three different values for the fractional part of just one x: let it be −1.3, its fractional part will be 0.7 according to the first definition, 0.3 according to the second definition, and −0.3 according to the third definition, whose result can also be obtained in a straightforward way by

$\operatorname {frac} (x)=x-\lfloor |x|\rfloor \cdot \operatorname {sgn} (x)$ .

The $x-\lfloor x\rfloor$ and the "odd function" definitions permit for unique decomposition of any real number x to the sum of its integer and fractional parts, where "integer part" refers to $\lfloor x\rfloor$ or $\lfloor |x|\rfloor \cdot \operatorname {sgn}(x)$ respectively. These two definitions of fractional-part function also provide idempotence.

The fractional part defined via difference from ⌊ ⌋ is usually denoted by curly braces:

$\{x\}:=x-\lfloor x\rfloor .$ Its range is the half-open interval [0, 1). For opposite numbers fractional parts complement as follows:

$\{x\}+\{-x\}={\begin{cases}0&{\mbox{ if }}x\in \mathbb {Z} \\1&{\mbox{ if }}x\not \in \mathbb {Z} .\end{cases}}$ ## Relation to continued fractions

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.