Everything

nexttoward / nexttowardf / nexttowardl


Calculates the next floating-point representation following d1 in the direction to d2 on the real axis.

[Format]

#include <math.h>

double nexttoward(double d1, long double d2);

float nexttowardf(float d1, long double d2);

long double nexttowardl(long double d1, long double d2);

[Parameters]

d1 Floating-point value on the real axis

d2 Value indicating the direction viewed from d1, in which a representable floating-point value is to be found

[Return values]

Normal: Representable floating-point value

Abnormal: Range error: Returns HUGE_VAL, HUGE_VALF, or HUGE_VALL with the mathematically correct sign depending on the function

[Remarks]

A range error may occur if d1 is the maximum finite value that can be represented in its value and the return value is an infinity or cannot be represented in its type.

The nexttoward function group is equivalent to the nextafter function group except that d2 is of type long double and returns d2 after conversion depending of the function when d1 is equal to d2.