#include <math.h> double nextafter(double x, double y); float nextafterf(float x, float y); long double nextafterl(long double x, long double y); double nexttoward(double x, long double y); float nexttowardf(float x, long double y); long double nexttowardl(long double x, long double y);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
nextafter():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| _XOPEN_SOURCE >= 500
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
nextafterf(), nextafterl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
nexttoward(), nexttowardf(), nexttowardl():
_XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
|| _POSIX_C_SOURCE >= 200112L
x が y と等しい場合、y が返される。
関数 nexttoward(), nexttowardf(), nexttowardl() は、2 番目の引数が long double 型である点以外、 対応する nextafter() 関数と同じはたらきをする。
x が y と等しい場合、 (x と同じ型にキャストされた) y が返される。
x か y が NaN の場合、NaN が返される。
x が有限値で 結果がオーバーフローする場合、 範囲エラー (range error) が発生し、 各関数はそれぞれ HUGE_VAL, HUGE_VALF, HUGE_VALL を返す。返り値には数学的に正しい符号が付与される。
x が y と同じではなく、正しい関数の結果が非正規化数かゼロかアンダーフローの場合、 範囲エラーが発生し、 (表現可能な場合には) 正しい値が、(そうでない場合には) 0.0 が返される。
以下のエラーが発生する可能性がある。
| インターフェース | 属性 | 値 |
| nextafter(), nextafterf(), nextafterl(), nexttoward(), nexttowardf(), nexttowardl() | Thread safety | MT-Safe |
この関数は IEC 559 で定義されている (また IEEE 754/IEEE 854 では付録で推奨関数として定義されている)。
Before glibc 2.23 these functions did not set errno.