Given a normalized floating point number f what is the next normalized floating point number after/before f.
With bit twiddling, extracting mantissa and exponent I have:
next_normalized(double&){
if mantissa is not all ones
maximally denormalize while maintaining equality
add 1 to mantissa
normalize
else
check overflow
set mantissa to 1
add (mantissa size in bits) to exponent.
endif
}
But rather than do that can it be done with floating point operations?
As
std::numeric_limits<double>::epsilon()
is only an error difference in a "neighborhood" of 1. - e.g.:
normalized(d+=std::numeric_limits<double>::epsilon()) = d for d large
it seems more an error ratio than an error difference, thus my naive intuition is
(1.+std::numeric_limits<double>::epsilon())*f //should be the next.
And
(1.-std::numeric_limits<double>::epsilon())*f //should be the previous.
In particular I have 3 questions has anyone done any of the following (for IEEE754):
1)done the error analysis on this issue?
2)proved (or can prove) that for any normalized double d
(1.+std::numeric_limits<double>::epsilon())*d != d ?
3)proved that for any normalized double number d no double f exists such that
d < f < (1.+std::numeric_limits<double>::epsilon())*d ?