OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[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 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Japanese Version Copyright (c) 2001, 2005 Yuichi SATO
26 .\" and Copyright (c) 2008 Akihiro MOTOKI
27 .\" Translated Fri Jul 13 20:33:41 JST 2001
28 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
29 .\" Updated & Modified Sun Jan 16 07:59:12 JST 2005
30 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
31 .\" Updated 2008-09-16, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
32 .\"
33 .\"WORD:        mantissa        ²¾¿ô
34 .\"
35 .TH ROUND 3  2010-09-20 "" "Linux Programmer's Manual"
36 .\"O .SH NAME
37 .SH Ì¾Á°
38 .\"O round, roundf, roundl \- round to nearest integer, away from zero
39 round, roundf, roundl \- ºÇ¤â¶á¤¤À°¿ôÃͤ˴ݤá¤ë (2 ¤Ä¤ÎÀ°¿ô¤ÎÃæ´ÖÃͤξì¹ç¤Ï 0 ¤«¤é±ó¤¤Êý¤Ë´Ý¤á¤ë)
40 .\"O .SH SYNOPSIS
41 .SH ½ñ¼°
42 .nf
43 .B #include <math.h>
44 .sp
45 .BI "double round(double " x );
46 .br
47 .BI "float roundf(float " x );
48 .br
49 .BI "long double roundl(long double " x );
50 .fi
51 .sp
52 .\"O Link with \fI\-lm\fP.
53 \fI\-lm\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
54 .sp
55 .in -4n
56 .\"O Feature Test Macro Requirements for glibc (see
57 .\"O .BR feature_test_macros (7)):
58 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
59 .RB ( feature_test_macros (7)
60 »²¾È):
61 .in
62 .sp
63 .ad l
64 .BR round (),
65 .BR roundf (),
66 .BR roundl ():
67 .RS 4
68 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
69 _POSIX_C_SOURCE\ >=\ 200112L;
70 .br
71 or
72 .I cc\ -std=c99
73 .RE
74 .ad
75 .\"O .SH DESCRIPTION
76 .SH ÀâÌÀ
77 .\"O These functions round \fIx\fP to the nearest integer, but
78 .\"O round halfway cases away from zero (regardless of the current rounding
79 .\"O direction, see
80 .\"O .BR fenv (3)),
81 .\"O instead of to the nearest even integer like
82 .\"O .BR rint (3).
83 ¤³¤ì¤é¤Î´Ø¿ô¤Ï \fIx\fP ¤òºÇ¤â¶á¤¤À°¿ôÃͤ˴ݤá¤ë¡£
84 2 ¤Ä¤ÎÀ°¿ô¤ÎÃæ´ÖÃͤξì¹ç¤Ï¡¢
85 .BR rint (3)
86 ¤Î¤è¤¦¤ËºÇ¤â¶á¤¤¶ö¿ô¤Ë´Ý¤á¤¿¤ê¤»¤º¤Ë¡¢
87 (¸½ºß¤Î´Ý¤áÊý¸þ¤Ë´Ø·¸¤Ê¤¯) 0 ¤«¤é±ó¤¤Êý¤Ë´Ý¤á¤ë
88 (´Ý¤áÊý¸þ¤Ë¤Ä¤¤¤Æ¤Ï
89 .BR fenv (3)
90 ¤ò»²¾È)¡£
91
92 .\"O For example,
93 .\"O .IR round(0.5)
94 .\"O is 1.0, and
95 .\"O .IR round(\-0.5)
96 .\"O is \-1.0.
97 Î㤨¤Ð¡¢
98 .I round(0.5)
99 ¤Ï 1.0 ¤Ç¡¢
100 .I round(\-0.5)
101 ¤Ï \-1.0 ¤Ç¤¢¤ë¡£
102 .\"O .SH "RETURN VALUE"
103 .SH ÊÖ¤êÃÍ
104 .\"O These functions return the rounded integer value.
105 ¤³¤ì¤é¤Î´Ø¿ô¤Ï´Ý¤á¤¿À°¿ôÃͤòÊÖ¤¹¡£
106
107 .\"O If \fIx\fP is integral, +0, \-0, NaN,  or infinite,
108 .\"O \fIx\fP itself is returned.
109 \fIx\fP ¤¬À°¿ô¡¢+0¡¢\-0¡¢NaN¡¢Ìµ¸Â¤Î¤¤¤º¤ì¤«¤Î¾ì¹ç¡¢
110 \fIx\fP ¤½¤Î¤â¤Î¤¬ÊÖ¤µ¤ì¤ë¡£
111 .\"O .SH ERRORS
112 .SH ¥¨¥é¡¼
113 .\"O No errors occur.
114 ¥¨¥é¡¼¤ÏȯÀ¸¤·¤Ê¤¤¡£
115 .\"O POSIX.1-2001 documents a range error for overflows, but see NOTES.
116 POSIX.1-2001 ¤Ë¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ç¤ÎÈÏ°Ï¥¨¥é¡¼ (range error) ¤Î
117 µ­ºÜ¤¬¤¢¤ë¡£¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È¡£
118 .\"O .SH VERSIONS
119 .SH ¥Ð¡¼¥¸¥ç¥ó
120 .\"O These functions first appeared in glibc in version 2.1.
121 ¤³¤ì¤é¤Î´Ø¿ô¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.1 ¤Ç½é¤á¤ÆÅо줷¤¿¡£
122 .\"O .SH "CONFORMING TO"
123 .SH ½àµò
124 C99, POSIX.1-2001.
125 .\"O .SH NOTES
126 .SH Ãí°Õ
127 .\"O POSIX.1-2001 contains text about overflow (which might set
128 .\"O .I errno
129 .\"O to
130 .\"O .BR ERANGE ,
131 .\"O or raise an
132 .\"O .B FE_OVERFLOW
133 .\"O exception).
134 POSIX.1-2001 ¤Ë¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ë´Ø¤¹¤ëµ­½Ò¤¬¤¢¤ê¡¢
135 ¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Î¾ì¹ç¤Ë¤Ï¡¢
136 .I errno
137 ¤ò
138 .B ERANGE
139 ¤ËÀßÄꤹ¤ë¤«¡¢
140 .B FE_OVERFLOW
141 Îã³°¤òȯÀ¸¤¹¤ë¤³¤È¤È¤µ¤ì¤Æ¤¤¤ë¡£
142 .\"O In practice, the result cannot overflow on any current machine,
143 .\"O so this error-handling stuff is just nonsense.
144 ¼ÂºÝ¤Î¤È¤³¤í¡¢¤É¤Î¸½¹Ô¤Î¥Þ¥·¥ó¤Ç¤Ï·ë²Ì¤¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤òµ¯¤³¤¹¤³¤È¤Ï¤Ê¤¤¤Î¤Ç¡¢
145 ¤³¤Î¥¨¥é¡¼½èÍý¤Ï°ÕÌ£¤¬¤Ê¤¤¡£
146 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
147 .\"O (More precisely, overflow can happen only when the maximum value
148 .\"O of the exponent is smaller than the number of mantissa bits.
149 .\"O For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
150 .\"O the maximum value of the exponent is 128 (respectively, 1024),
151 .\"O and the number of mantissa bits is 24 (respectively, 53).)
152 (¤è¤êÀµ³Î¤Ë¸À¤¦¤È¡¢¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ï»Ø¿ôÉô¤ÎºÇÂçÃͤ¬
153 ²¾¿ôÉô¤òɽ¤¹¥Ó¥Ã¥È¤Î¿ô¤è¤ê¾®¤µ¤¤¾ì¹ç¤Ë¤·¤«µ¯¤³¤é¤Ê¤¤¡£
154 IEEE-754 µ¬³Ê¤Î 32 ¥Ó¥Ã¥È¤È 64 ¥Ó¥Ã¥È¤ÎÉâÆ°¾®¿ô¤Ç¤Ï¡¢
155 »Ø¿ôÉô¤ÎºÇÂçÃͤϤ½¤ì¤¾¤ì 128 ¤È 1024 ¤Ç¤¢¤ê¡¢
156 ²¾¿ôÉô¤Î¥Ó¥Ã¥È¿ô¤Ï¤½¤ì¤¾¤ì 24 ¤È 53 ¤Ç¤¢¤ë¡£)
157
158 .\"O If you want to store the rounded value in an integer type,
159 .\"O you probably want to use one of the functions described in
160 .\"O .BR lround (3)
161 .\"O instead.
162 ´Ý¤á¤¿ÃͤòÀ°¿ô·¿¤Ë³ÊǼ¤·¤¿¾ì¹ç¤Ë¤Ï¡¢¤ª¤½¤é¤¯¤³¤Î´Ø¿ô¤Ç¤Ï¤Ê¤¯
163 .BR lround (3)
164 ¤ËºÜ¤Ã¤Æ¤¤¤ë´Ø¿ô¤Î¤É¤ì¤«¤ò»È¤¤¤¿¤¤¤Î¤À¤í¤¦¡£
165 .\"O .SH "SEE ALSO"
166 .SH ´ØÏ¢¹àÌÜ
167 .BR ceil (3),
168 .BR floor (3),
169 .BR lround (3),
170 .BR nearbyint (3),
171 .BR rint (3),
172 .BR trunc (3)