nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
Defined in header <math.h>
|
||
float nextafterf( float from, float to ); |
(1) | (since C99) |
double nextafter( double from, double to ); |
(2) | (since C99) |
long double nextafterl( long double from, long double to ); |
(3) | (since C99) |
float nexttowardf( float from, long double to ); |
(4) | (since C99) |
double nexttoward( double from, long double to ); |
(5) | (since C99) |
long double nexttowardl( long double from, long double to ); |
(6) | (since C99) |
Defined in header <tgmath.h>
|
||
#define nextafter(from, to) |
(7) | (since C99) |
#define nexttoward(from, to) |
(8) | (since C99) |
from
in the direction of to
. If from
equals to to
, to
is returned.from
in the direction of to
. If from
equals to to
, to
is returned, converted from long double to the return type of the function without loss of range or precision.nextafterl
is called. Otherwise, if any argument has integer type or has type double, nextafter
is called. Otherwise, nextafterf
is called.from
has type long double, nexttowardl
is called. Otherwise, if from
has integer type or the type double, nexttoward
is called. Otherwise, nexttowardf
is called.Parameters
from, to | - | floating point values |
Return value
If no errors occur, the next representable value of from
in the direction of to
. is returned. If from
equals to
, then to
is returned, converted to the type of the function.
If a range error due to overflow occurs, ±HUGE_VAL
, ±HUGE_VALF
, or ±HUGE_VALL
is returned (with the same sign as from
).
If a range error occurs due to underflow, the correct result is returned.
Error handling
Errors are reported as specified in math_errhandling.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
- if
from
is finite, but the expected result is an infinity, raises FE_INEXACT and FE_OVERFLOW - if
from
does not equalto
and the result is subnormal or zero, raises FE_INEXACT and FE_UNDERFLOW - in any case, the returned value is independent of the current rounding mode
- if either
from
orto
is NaN, NaN is returned
Notes
POSIX specifies that the overflow and the underflow conditions are range errors (errno may be set).
IEC 60559 recommends that from
is returned whenever from==to
. These functions return to
instead, which makes the behavior around zero consistent: nextafter(-0.0, +0.0)
returns +0.0
and nextafter(+0.0, -0.0)
returns –0.0
.