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()
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.