Double-precision floating point (±1.7E±308, ~15 decimal digits)
1st Parameter
The starting floating-point value.
2nd Parameter Type : long double
A floating-point type with extended precision, typically larger than `double` and used for high-precision arithmetic. The size and precision depend on the platform but are often 80 or 128 bits.
2nd Parameter
The target long double value towards which `x` will be incremented or decremented.
Read more about parameters of nexttoward in parameters section
The nexttowardfunction in C language Returns the next representable value of the first argument towards the second argument, specified as a long double.
The nexttoward function returns the next representable double-precision floating-point value following x in the direction of y (specified as a long double). If x equals y, the function returns y converted to double. If either x or y is NaN, NaN is returned. This function is similar to nextafter but allows for higher precision in the second argument.
The nexttowardfunction takes 2
parameters:
•
double `x`: The starting floating-point value.
•
long double `y`: The target long double value towards which `x` will be incremented or decremented.
Returns the next representable floating-point value after `x` in the direction of `y`, where `y` is of type `long double` for extended precision. 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 with extended precision targets.
The nexttoward function return value :
Returns the next representable double value after x in the direction of y
Output
This example demonstrates how nexttoward finds the next representable double value towards a long double direction.