.\" Copyright 2001 Andries Brouwer . .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk .\" .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi .\" and Copyright (c) 2008 Akihiro MOTOKI .\" Translated Tue Jan 21 20:52:09 JST 1997 .\" by YOSHINO Takashi .\" Updated & Modified Fri Jul 6 20:42:59 JST 2001 .\" by Yuichi SATO .\" Updated & Modified Sun Jan 16 07:40:37 JST 2005 .\" by Yuichi SATO .\" Updated 2008-09-16, Akihiro MOTOKI .\" .\"WORD: mantissa 仮数 .\" .TH RINT 3 2010-09-20 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round .\"O to nearest integer nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- 最も近い整数に丸める .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "double nearbyint(double " x ); .br .BI "float nearbyintf(float " x ); .br .BI "long double nearbyintl(long double " x ); .sp .BI "double rint(double " x ); .br .BI "float rintf(float " x ); .br .BI "long double rintl(long double " x ); .fi .sp .\"O Link with \fI\-lm\fP. \fI\-lm\fP でリンクする。 .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .ad l .BR nearbyint (), .BR nearbyintf (), .BR nearbyintl (): .RS 4 _XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L || _ISOC99_SOURCE; .br or .I cc\ -std=c99 .RE .br .BR rint (): .RS 4 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L; .br or .I cc\ -std=c99 .RE .br .BR rintf (), .BR rintl (): .RS 4 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L; .br or .I cc\ -std=c99 .RE .ad b .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR nearbyint () .\"O functions round their argument to an integer value in floating-point .\"O format, using the current rounding direction (see .\"O .BR fesetround (3)) .\"O and without raising the .\"O .I inexact .\"O exception. .BR nearbyint () 関数群は、現在の丸め方向 .RB ( fesetround (3) 参照) で引き数を浮動小数点形式の整数に丸める。 .I inexact 例外を出さない。 .LP .\"O The .\"O .BR rint () .\"O functions do the same, but will raise the .\"O .I inexact .\"O exception .\"O .RB ( FE_INEXACT , .\"O checkable via .\"O .BR fetestexcept (3)) .\"O when the result differs in value from the argument. .BR rint () 関数群も同じような動作をするが、 結果が引き数と異なる場合に .I inexact 例外 .RB ( FE_INEXACT ) を出す (この例外は .BR fetestexcept (3) 経由で確認可能)。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O These functions return the rounded integer value. これらの関数は丸めた整数値を返す。 .\"O If \fIx\fP is integral, +0, \-0, NaN, or infinite, .\"O \fIx\fP itself is returned. \fIx\fP が整数、+0、\-0、NaN、無限大のいずれかの場合、 \fIx\fP そのものを返す。 .\"O .SH ERRORS .SH エラー .\"O No errors occur. エラーは発生しない。 .\"O POSIX.1-2001 documents a range error for overflows, but see NOTES. POSIX.1-2001 にはオーバーフローでの範囲エラー (range error) の 記載がある。「注意」の節を参照のこと。 .\"O .SH "CONFORMING TO" .SH 準拠 C99, POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O SUSv2 and POSIX.1-2001 contain text about overflow (which might set .\"O .I errno .\"O to .\"O .BR ERANGE , .\"O or raise an .\"O .B FE_OVERFLOW .\"O exception). SUSv2 と POSIX.1-2001 にはオーバーフローに関する記述があり、 オーバーフローの場合には、 .I errno を .B ERANGE に設定するか、 .B FE_OVERFLOW 例外を発生することとされている。 .\"O In practice, the result cannot overflow on any current machine, .\"O so this error-handling stuff is just nonsense. 実際のところ、どの現行のマシンでも結果がオーバーフローを起こすことはないので、 このエラー処理は意味がない。 .\"O (More precisely, overflow can happen only when the maximum value .\"O of the exponent is smaller than the number of mantissa bits. .\"O For the IEEE-754 standard 32-bit and 64-bit floating-point numbers .\"O the maximum value of the exponent is 128 (respectively, 1024), .\"O and the number of mantissa bits is 24 (respectively, 53).) (より正確に言うと、オーバーフローは指数部の最大値が 仮数部を表すビットの数より小さい場合にしか起こらない。 IEEE-754 規格の 32 ビットと 64 ビットの浮動小数では、 指数部の最大値はそれぞれ 128 と 1024 であり、 仮数部のビット数はそれぞれ 24 と 53 である。) .\"O If you want to store the rounded value in an integer type, .\"O you probably want to use one of the functions described in .\"O .BR lrint (3) .\"O instead. 丸めた値を整数型に格納した場合には、おそらくこの関数ではなく .BR lrint (3) に載っている関数のどれかを使いたいのだろう。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR ceil (3), .BR floor (3), .BR lrint (3), .BR round (3), .BR trunc (3)