Consider a "normal" real number TREAL x
in C++ (not subnormal and not NaN/Infinite) (TREAL
= float
, double
, long double
)
Is the following the good solution to find the previous and next x
from a floating-point point of view ?
TREAL xprev = (((TREAL)(1.)) - std::numeric_limits<TREAL>::epsilon()) * x;
TREAL xnext = (((TREAL)(1.)) + std::numeric_limits<TREAL>::epsilon()) * x;
Thank you very much.