I have a double value f and would like a way to nudge it very slightly larger (or smaller) to get a new value that will be as close as possible to
double
f
I needed to do the exact same thing and came up with this code:
double DoubleIncrement(double value) { int exponent; double mantissa = frexp(value, &exponent); if(mantissa == 0) return DBL_MIN; mantissa += DBL_EPSILON/2.0f; value = ldexp(mantissa, exponent); return value; }