def is_essentially(ref_value, value, round_error=1e-14):
    """Returns True if value is within round_error distance from ref_value.

    ref_value -- int or float, number
    value -- int or float, number
    round_error -- limit on deviation from ref_value, default=1e-14

    This function differs from fix_rounding_error:
    - it returns a boolean, not 1 or 0. 
    - it checks the lower bound as well, not only if 
        ref_value < value < ref_value+round_error
    """
    if ref_value-round_error < value < ref_value+round_error:
        return True
    return False

def is_essentially_one(x, round_error=1e-14):
    """Returns True if x is within round_error distance from 1.

    x: number
    round_error: limit on deviation from 1, default=1e-14

    This function differs from fix_rounding_error:
    - it returns a boolean, not 1 or 0. 
    - it checks the lower bound as well, not only if 1 < x < 1+round_error
    """
    return is_essentially(1, x, round_error)
    if 1-round_error < x < 1+round_error:
        return True
    return False

def is_essentially_zero(x, round_error=1e-14):
    """Returns True if x is within round_error distance from 0.

    x: number
    round_error: limit on deviation from 1, default=1e-14

    This function differs from fix_rounding_error:
    - it returns a boolean, not 1 or 0. 
    - it checks the lower bound as well, not only if 1 < x < 1+round_error
    """
    return is_essentially(0, x, round_error)
    if 0-round_error < x < 0+round_error:
        return True
    return False



