Include <cmath>
and call std::nextafter
, and your code will work, provided you have a C++11 compiler.
Including <math.h>
and calling ::nextafter
invokes the C version of the function. The C implementation of nextafter
obviously supports no overloads, so C provides a nextafterf
for single-precision result, as well as nextafterl
for quad-precision. (Simply calling double-precision nextafter
with float
fails because the argument gets converted to double
.) If you don't have a C++11 compiler, you can fix your code by invoking ::nextafterf
.