namespace std {
float nextafter(float x, float y);
double nextafter(double x, double y);
long double nextafter(long double x, long double y);
Promoted nextafter(Arithmetic1 x, Arithmetic2 y);
float nextafterf(float x, float y); // C++17 から
long double nextafterl(long double x, long double y); // C++17 から
}
概要
指定方向への次の表現可能な値を取得する。
この関数は、パラメータx
の値をパラメータy
の値の方向に対して、その環境で表現可能な最小の値だけ進める。
戻り値
パラメータx
の値をパラメータx
の方向に、表現可能な最小の値だけ進めた値を返す。
x
とy
が等値である場合、y
を返す。
進めた結果が無限大、もしくは表現できない場合、値域エラーとなる。
例
出力例
1.4013e-45
-1.4013e-45
備考
特定の環境で constexpr
指定されている場合がある。(独自拡張)
- GCC 4.6.1 以上
バージョン
言語
- C++11
処理系
- Clang: 3.0
- GCC: 4.3
- ICC: ??
- Visual C++: ??