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
の方向に返します。 x
と y
が等しい場合、この関数は、戻り値の型に変換された y
を、例外をトリガーすることなく返します。 が等y
しくない場合、結果が非正規化またはゼロの場合x
、浮動小数点例外のFE_UNDERFLOW
FE_INEXACT
状態が設定され、正しい結果が返されます。 x
または y
が NAN の場合、戻り値は入力 NAN のいずれかとなります。 x
が有限であり、結果が無限、または型で表現できない場合、正しく署名された無限大または NAN が返され、FE_OVERFLOW
と FE_INEXACT
の浮動小数点例外の状態が設定され、errno
が ERANGE
に設定されます。
解説
nextafter
と nexttoward
の関数ファミリは、y
のパラメーターの型を除いて同等です。 x
と y
が等しい場合、戻り値は戻り値の型に変換された y
になります。
C++ ではオーバーロードが可能であるため、<cmath>
を含めると、float
と long double
型を返す nextafter
と nexttoward
のオーバーロードを呼び出すことができます。 C プログラムでは、この関数を呼び出すために <tgmath.h>
マクロが使用されていない限り、nextafter
と nexttoward
は常に 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」を参照してください。
関連項目
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示