Name
nextafter
Synopsis
Obtains the next representable value
#include <math.h> doublenextafter( doublex, doubley); floatnextafterf( floatx, floaty); long doublenextafterl( long doublex, long doubley);
The nextafter() function
returns the next value to the first argument
x, removed from it in the direction
toward the value of y, that is
representable in the function’s type. If the values of the two
arguments are equal, nextafter()
returns the value of the second argument
y.
If the argument x has the magnitude
of the largest finite value that can be represented in the
function’s type, and the result is not a finite, representable
value, then a range error may occur.
Example
double x =nextafter( 0.0, 1.0 );
printf("The smallest positive number "
"with the type double: %E\n", x);This code produces output like the following:
The smallest positive number with the type double: 4.940656E-324
See Also
nexttoward(), nearbyint(), rint(), lrint(), llrint(), round(), lround(), llround(), ceil(), floor()
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access