function
<cmath> <ctgmath>

# nextafter

```     double 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 );
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.
Additional overloads are provided in this header (`<cmath>`) for other combinations of arithmetic types (Type1 and 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).

### Parameters

x
Base value.
y
Value toward which the return value is approximated.
If both parameters compare equal, the function returns y.

### Return Value

The next representable value after x in the direction of y.

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:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to ERANGE.
- And math_errhandling has MATH_ERREXCEPT set: FE_OVERFLOW is raised.

### Example

 ``12345678910`` ``````/* nextafter example */ #include /* printf */ #include /* 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; }``````

Possible output:
 ``` first representable value greater than zero: 4.940656e-324 first representable value less than zero: -4.940656e-324 ```