import math


def next_float(value, greater=True):
    """Gets the next (or previous) floating point value."""
    frac, exponent = math.frexp(value)
    if greater:
        if frac == -0.5:
            ulp = 0.5 ** 54
        else:
            ulp = 0.5 ** 53
    else:
        if frac == 0.5:
            ulp = -0.5 ** 54
        else:
            ulp = -0.5 ** 53

    return (frac + ulp) * 2.0 ** exponent