import math


def mod_one(x):
    """
    Reduce a number modulo 1.

    INPUT:

    - ``x`` - an instance of Integer, int, RealNumber, etc.; the
      number to reduce

    OUTPUT:

    - a float

    EXAMPLES::

        sage: from sage.plot.colors import mod_one
        sage: mod_one(1)
        1.0
        sage: mod_one(7.0)
        0.0
        sage: mod_one(-11/7)
        0.4285714285714286
        sage: mod_one(pi) + mod_one(-pi)
        1.0
    """
    x = float(x)
    if x != 1:
        x = math.modf(x)[0]
        if x < 0:
            x += 1
    return x