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);
-lm でリンクする。
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
nextafter():
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE; or
cc -std=c99
nextafterf(),
nextafterl():
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or
cc -std=c99
nexttoward(),
nexttowardf(),
nexttowardl():
_XOPEN_SOURCE >= 600 || _ISOC99_SOURCE;
cc -std=c99
x が y と等しい場合、y が返される。
nexttoward() 関数群は、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 が返される。
以下のエラーが発生する可能性がある。