Double-precision floating point (±1.7E±308, ~15 decimal digits)
1st Parameter
The starting floating-point value.
2nd Parameter Type : double
Double-precision floating point (±1.7E±308, ~15 decimal digits)
2nd Parameter
The target floating-point value towards which `x` will be incremented or decremented.
Read more about parameters of nextafter in parameters section
The nextafterfunction in C language Returns the next representable value of the first argument in the direction of the second argument.
The nextafter function returns the next representable double-precision floating-point value following x in the direction of y. If x equals y, the function returns y. If either x or y is NaN, NaN is returned.
The nextafterfunction takes 2
parameters:
•
double `x`: The starting floating-point value.
•
double `y`: The target floating-point value towards which `x` will be incremented or decremented.
Returns the next representable floating-point value after `x` in the direction of `y`. If `x` equals `y`, the function returns `y`. Handles subnormal values and overflows, returning ±infinity in the latter case. Useful for precise floating-point arithmetic and rounding.
The nextafter function return value :
Returns the next representable value after x in the direction of y
Output
This example shows how nextafter finds the next representable value in both positive and negative directions from zero.