OSDN Git Service

(split) LDP: Restore and add Copyrights for draft pages
[linuxjm/LDP_man-pages.git] / draft / man3 / round.3
1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\"*******************************************************************
28 .\"
29 .\" This file was generated with po4a. Translate the source file.
30 .\"
31 .\"*******************************************************************
32 .\"
33 .\" Japanese Version Copyright (c) 2001, 2005 Yuichi SATO
34 .\" and Copyright (c) 2008 Akihiro MOTOKI
35 .\" Translated Fri Jul 13 20:33:41 JST 2001
36 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
37 .\" Updated & Modified Sun Jan 16 07:59:12 JST 2005
38 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
39 .\" Updated 2008-09-16, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\"
41 .TH ROUND 3 2013\-06\-21 "" "Linux Programmer's Manual"
42 .SH 名前
43 round, roundf, roundl \- 最も近い整数値に丸める (2 つの整数の中間値の場合は 0 から遠い方に丸める)
44 .SH 書式
45 .nf
46 \fB#include <math.h>\fP
47 .sp
48 \fBdouble round(double \fP\fIx\fP\fB);\fP
49 .br
50 \fBfloat roundf(float \fP\fIx\fP\fB);\fP
51 .br
52 \fBlong double roundl(long double \fP\fIx\fP\fB);\fP
53 .fi
54 .sp
55 \fI\-lm\fP でリンクする。
56 .sp
57 .in -4n
58 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
59 .in
60 .sp
61 .ad l
62 \fBround\fP(), \fBroundf\fP(), \fBroundl\fP():
63 .RS 4
64 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L;
65 .br
66 or \fIcc\ \-std=c99\fP
67 .RE
68 .ad
69 .SH 説明
70 これらの関数は \fIx\fP を最も近い整数値に丸める。 2 つの整数の中間値の場合は、 \fBrint\fP(3)  のように最も近い偶数に丸めたりせずに、
71 (現在の丸め方向に関係なく) 0 から遠い方に丸める (丸め方向については \fBfenv\fP(3)  を参照)。
72
73 例えば、 \fIround(0.5)\fP は 1.0 で、 \fIround(\-0.5)\fP は \-1.0 である。
74 .SH 返り値
75 これらの関数は丸めた整数値を返す。
76
77 \fIx\fP が整数、+0、\-0、NaN、無限のいずれかの場合、 \fIx\fP そのものが返される。
78 .SH エラー
79 エラーは発生しない。 POSIX.1\-2001 にはオーバーフローでの範囲エラー (range error) の 記載がある。「注意」の節を参照のこと。
80 .SH バージョン
81 これらの関数は glibc バージョン 2.1 で初めて登場した。
82 .SH 属性
83 .SS "マルチスレッディング (pthreads(7) 参照)"
84 関数 \fBround\fP(), \fBroundf\fP(), \fBroundl\fP() はスレッドセーフである。
85 .SH 準拠
86 C99, POSIX.1\-2001.
87 .SH 注意
88 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
89 POSIX.1\-2001 にはオーバーフローに関する記述があり、 オーバーフローの場合には、 \fIerrno\fP を \fBERANGE\fP に設定するか、
90 \fBFE_OVERFLOW\fP 例外を発生することとされている。 実際のところ、どの現行のマシンでは結果がオーバーフローを起こすことはないので、
91 このエラー処理は意味がない。 (より正確に言うと、オーバーフローは指数部の最大値が 仮数部を表すビットの数より小さい場合にしか起こらない。
92 IEEE\-754 規格の 32 ビットと 64 ビットの浮動小数では、 指数部の最大値はそれぞれ 128 と 1024 であり、
93 仮数部のビット数はそれぞれ 24 と 53 である。)
94
95 丸めた値を整数型に格納した場合には、おそらくこの関数ではなく \fBlround\fP(3)  に載っている関数のどれかを使いたいのだろう。
96 .SH 関連項目
97 \fBceil\fP(3), \fBfloor\fP(3), \fBlround\fP(3), \fBnearbyint\fP(3), \fBrint\fP(3),
98 \fBtrunc\fP(3)
99 .SH この文書について
100 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
101 である。プロジェクトの説明とバグ報告に関する情報は
102 http://www.kernel.org/doc/man\-pages/ に書かれている。