C examples for math.h:nexttoward
function
<cmath> <ctgmath> <math.h>
Returns the next representable value after x in the direction of y.
If both parameters compare equal, the function returns y converted to the return type.
long double nexttowardl (long double x, long double y); long double nexttoward (long double x, long double y); double nexttoward (double x , long double y); float nexttowardf (float x , long double y); float nexttoward (float x , long double y); double nexttoward (T x , long double y);
Parameter | Description |
---|---|
x | Base value. |
y | Value toward which the return value is approximated. |
The next representable value after x in the direction of y.
#include <stdio.h> #include <math.h> /* nexttoward */ int main ()// w ww. j ava2 s. c om { printf ("first representable value greater than zero: %e\n", nexttoward(0.0,1.0L)); printf ("first representable value less than zero: %e\n", nexttoward(0.0,-1.0L)); printf ("%e\n", nexttoward(10.0,-1.0L)); return 0; }