.\" 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) 2001, 2005 Yuichi SATO .\" and Copyright (c) 2008 Akihiro MOTOKI .\" Translated Fri Jul 13 20:33:41 JST 2001 .\" by Yuichi SATO .\" Updated & Modified Sun Jan 16 07:59:12 JST 2005 .\" by Yuichi SATO .\" Updated 2008-09-16, Akihiro MOTOKI .\" .\"WORD: mantissa 仮数 .\" .TH ROUND 3 2010-09-20 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O round, roundf, roundl \- round to nearest integer, away from zero round, roundf, roundl \- 最も近い整数値に丸める (2 つの整数の中間値の場合は 0 から遠い方に丸める) .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "double round(double " x ); .br .BI "float roundf(float " x ); .br .BI "long double roundl(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 round (), .BR roundf (), .BR roundl (): .RS 4 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L; .br or .I cc\ -std=c99 .RE .ad .\"O .SH DESCRIPTION .SH 説明 .\"O These functions round \fIx\fP to the nearest integer, but .\"O round halfway cases away from zero (regardless of the current rounding .\"O direction, see .\"O .BR fenv (3)), .\"O instead of to the nearest even integer like .\"O .BR rint (3). これらの関数は \fIx\fP を最も近い整数値に丸める。 2 つの整数の中間値の場合は、 .BR rint (3) のように最も近い偶数に丸めたりせずに、 (現在の丸め方向に関係なく) 0 から遠い方に丸める (丸め方向については .BR fenv (3) を参照)。 .\"O For example, .\"O .IR round(0.5) .\"O is 1.0, and .\"O .IR round(\-0.5) .\"O is \-1.0. 例えば、 .I round(0.5) は 1.0 で、 .I round(\-0.5) は \-1.0 である。 .\"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 VERSIONS .SH バージョン .\"O These functions first appeared in glibc in version 2.1. これらの関数は glibc バージョン 2.1 で初めて登場した。 .\"O .SH "CONFORMING TO" .SH 準拠 C99, POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O POSIX.1-2001 contains text about overflow (which might set .\"O .I errno .\"O to .\"O .BR ERANGE , .\"O or raise an .\"O .B FE_OVERFLOW .\"O exception). 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. 実際のところ、どの現行のマシンでは結果がオーバーフローを起こすことはないので、 このエラー処理は意味がない。 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point. .\"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 lround (3) .\"O instead. 丸めた値を整数型に格納した場合には、おそらくこの関数ではなく .BR lround (3) に載っている関数のどれかを使いたいのだろう。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR ceil (3), .BR floor (3), .BR lround (3), .BR nearbyint (3), .BR rint (3), .BR trunc (3)