function
<cmath> <ctgmath>
nextafterdouble nextafter (double x , double y); float nextafterf (float x , float y);long double nextafterl (long double x, long double y);
double nextafter (double x , double y ); float nextafter (float x , float y );long double nextafter (long double x, long double y ); double nextafter (Type1 x , Type2 y); // additional overloads
Next representable value
Returns the next representable value after x in the direction of y.The similar function, nexttoward has the same behavior, but it takes a long double
as second argument.
Header
<tgmath.h>provides a type-generic macro version of this function.
are provided in this header (
<cmath>
) for other combinations of
arithmetic types(
Type1and
Type2): These overloads effectively cast its arguments to
double
before calculations, except if at least one of the arguments is of type
long double
(in which case both are casted to
long double
instead).
If x is the largest finite value representable in the type, and the result is infinite or not representable, an overflow range error occurs.
If an overflow range error occurs:
1
2
3
4
5
6
7
8
9
10
/* nextafter example */
#include <stdio.h> /* printf */
#include <math.h> /* nextafter */
int main ()
{
printf ("first representable value greater than zero: %e\n", nextafter(0.0,1.0));
printf ("first representable value less than zero: %e\n", nextafter(0.0,-1.0));
return 0;
}
first representable value greater than zero: 4.940656e-324 first representable value less than zero: -4.940656e-324
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4