nextafterのヘルプ・マニュアル
日本語 英語
nextafter --help
man nextafter
NEXTAFTER(3) Linux Programmer’s Manual NEXTAFTER(3)
名前
nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
- 浮動小数点数の操作
書式
#include
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
説明
nextafter() 関数群は、y に向かう方向で x のすぐ次の浮動小数点数表現を返
す。 y が x より小さい場合、 y より小さい最大の浮動小数点表現の値を返す
。
x が y と等しい場合、y が返される。
nexttoward() 関 数群は、2 番目の引き数が long double 型である点以外、
nextafter() 関数群と同じはたらきをする。
返り値
成功すると、これらの関数は y に向かう方向で x のすぐ次の浮動小数点数 表
現を返す。
x が y と等しい場合、 (x と同じ型にキャストされた) y が返される。
x か y が NaN の場合、NaN が返される。
x が有限値で結果がオーバーフローする場合、範囲エラー (range error) が発
生し、各関数はそれぞれ HUGE_VAL, HUGE_VALF, HUGE_VALL を返す。返り値 に
は数学的に正しい符号が付与される。
x が y と同じではなく、正しい関数の結果が非正規化数かゼロかアンダーフロ
ーの場合、範囲エラーが発生し、 (表現可能な場合には) 正しい値が、(そうで
ない場合には) 0.0 が返される。
エラー
こ れらの関数を呼び出した際にエラーが発生したかの判定方法についての情報
は math_error(7) を参照のこと。
以下のエラーが発生する可能性がある。
範囲エラー: 結果のオーバーフロー
オーバーフロー浮動小数点例外 (FE_OVERFLOW) が上がる。
範囲エラー: 結果が非正規化数かアンダーフロー
アンダーフロー浮動小数点例外 (FE_UNDERFLOW) が上がる。
これらの関数は errno を設定しない。
準拠
C99, POSIX.1-2001. この関数は IEC 559 で定義されている。 ( ま た IEEE
754/IEEE 854 では付録で推奨関数として定義されている)
バグ
glibc バージョン 2.5 以前では、アンダーフローが発生した際に、これらの関
数はアンダーフロー浮動小数点例外 (FE_UNDERFLOW) を上がない。
関連項目
nearbyint(3)
GNU 2008-10-06 NEXTAFTER(3)
NEXTAFTER(3) Linux Programmer’s Manual NEXTAFTER(3)
NAME
nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
- floating-point number manipulation
SYNOPSIS
#include
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);
Link with -lm.
Feature Test Macro Requirements for glibc (see 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
DESCRIPTION
The nextafter() functions return the next representable floating-point
value following x in the direction of y. If y is less than x, these
functions will return the largest representable number less than y.
If x equals y, the functions return y.
The nexttoward() functions do the same as the nextafter() functions,
except that they have a long double second argument.
RETURN VALUE
On success, these functions return the next representable floating-
point value after x in the direction of y.
If x equals y, then y (cast to the same type as x) is returned.
If x or y is a NaN, a NaN is returned.
If x is finite, and the result would overflow, a range error occurs,
and the functions return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respec-
tively, with the correct mathematical sign.
If x is not equal to y, and the correct function result would be sub-
normal, zero, or underflow, a range error occurs, and either the cor-
rect value (if it can be represented), or 0.0, is returned.
ERRORS
See math_error(7) for information on how to determine whether an error
has occurred when calling these functions.
The following errors can occur:
Range error: result overflow
An overflow floating-point exception (FE_OVERFLOW) is raised.
Range error: result is subnormal or underflows
An underflow floating-point exception (FE_UNDERFLOW) is raised.
These functions do not set errno.
CONFORMING TO
C99, POSIX.1-2001. This function is defined in IEC 559 (and the
appendix with recommended functions in IEEE 754/IEEE 854).
BUGS
In glibc version 2.5 and earlier, these functions do not raise an
underflow floating-point (FE_UNDERFLOW) exception when an underflow
occurs.
SEE ALSO
nearbyint(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2008-10-06 NEXTAFTER(3)