<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fmt_number(p):
 """Format a number. It will be printed as a fraction if the denominator isn't too big and as a decimal otherwise. """

    formatted = '{:n}'.format(p)

    if not config.PRINT_FRACTIONS:
        return formatted

    fraction = Fraction(p)
    nice = fraction.limit_denominator(128)
    return (
        str(nice) if (abs(fraction - nice) < constants.EPSILON and
                      nice.denominator in NICE_DENOMINATORS)
        else formatted
    )