nextafter, nextafterf, nextafterl, _nextafter, _nextafterf, nexttoward, nexttowardf, nexttowardl

次の表現可能な浮動小数点値を返します。

構文

double nextafter( double x, double y );
float nextafterf( float x, float y );
long double nextafterl( long double x, long double y );

double _nextafter( double x, double y );
float _nextafterf( float x, float y ); /* x64 only */

#define nextafter(X, Y) // Requires C11 or higher

double nexttoward( double x, long double y );
float nexttowardf( float x, long double y );
long double nexttowardl( long double x, long double y );

#define nexttoward(X, Y) // Requires C11 or higher

float nextafter( float x, float y ); /* C++ only, requires <cmath> */
long double nextafter( long double x, long double y ); /* C++ only, requires <cmath> */

float nexttoward( float x, long double y ); /* C++ only, requires <cmath> */
long double nexttoward( long double x, long double y ); /* C++ only, requires <cmath> */

パラメーター

x
開始する浮動小数点値。

y
移動する浮動小数点値。

戻り値

x の後の戻り値の型の、次の表現可能な浮動小数点値を y の方向に返します。 xy が等しい場合、この関数は、戻り値の型に変換された y を、例外をトリガーすることなく返します。 が等yしくない場合、結果が非正規化またはゼロの場合x、浮動小数点例外のFE_UNDERFLOWFE_INEXACT状態が設定され、正しい結果が返されます。 x または y が NAN の場合、戻り値は入力 NAN のいずれかとなります。 x が有限であり、結果が無限、または型で表現できない場合、正しく署名された無限大または NAN が返され、FE_OVERFLOWFE_INEXACT の浮動小数点例外の状態が設定され、errnoERANGE に設定されます。

解説

nextafternexttoward の関数ファミリは、y のパラメーターの型を除いて同等です。 xy が等しい場合、戻り値は戻り値の型に変換された y になります。

C++ ではオーバーロードが可能であるため、<cmath> を含めると、floatlong double 型を返す nextafternexttoward のオーバーロードを呼び出すことができます。 C プログラムでは、この関数を呼び出すために <tgmath.h> マクロが使用されていない限り、nextafternexttoward は常に double を返します。

またはnexttowardマクロ<tgmath.h>を使用するnextafter場合は、引数の型によって、選択される関数のバージョンが決まります。 詳細については、「ジェネリック型数値演算」を参照してください。

_nextafter_nextafterf は、Microsoft 固有の関数です。 _nextafterf 関数は、x64 用にコンパイルするときにのみ使用できます。

既定では、この関数のグローバル状態の適用対象は、アプリケーションになります。 この動作を変更するには、「CRT のグローバル状態」を参照してください

必要条件

ルーチンによって返される値 必須ヘッダー (C) 必須ヘッダー (C++)
nextafter, nextafterf, nextafterl, _nextafterf, nexttoward, nexttowardf, nexttowardl <math.h> <math.h> または <cmath>
_nextafter <float.h> <float.h> または <cfloat>
nextafter マクロ、nexttoward マクロ <tgmath.h>

互換性の詳細については、「 Compatibility」を参照してください。

関連項目

数学と浮動小数点のサポート
isnan, _isnan, _isnanf