1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
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>
33 .\"WORD: mantissa ²¾¿ô
35 .TH ROUND 3 2010-09-20 "" "Linux Programmer's Manual"
38 .\"O round, roundf, roundl \- round to nearest integer, away from zero
39 round, roundf, roundl \- ºÇ¤â¶á¤¤À°¿ôÃͤ˴ݤá¤ë (2 ¤Ä¤ÎÀ°¿ô¤ÎÃæ´ÖÃͤξì¹ç¤Ï 0 ¤«¤é±ó¤¤Êý¤Ë´Ý¤á¤ë)
45 .BI "double round(double " x );
47 .BI "float roundf(float " x );
49 .BI "long double roundl(long double " x );
52 .\"O Link with \fI\-lm\fP.
53 \fI\-lm\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
56 .\"O Feature Test Macro Requirements for glibc (see
57 .\"O .BR feature_test_macros (7)):
58 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
59 .RB ( feature_test_macros (7)
68 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
69 _POSIX_C_SOURCE\ >=\ 200112L;
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
81 .\"O instead of to the nearest even integer like
83 ¤³¤ì¤é¤Î´Ø¿ô¤Ï \fIx\fP ¤òºÇ¤â¶á¤¤À°¿ôÃͤ˴ݤá¤ë¡£
84 2 ¤Ä¤ÎÀ°¿ô¤ÎÃæ´ÖÃͤξì¹ç¤Ï¡¢
86 ¤Î¤è¤¦¤ËºÇ¤â¶á¤¤¶ö¿ô¤Ë´Ý¤á¤¿¤ê¤»¤º¤Ë¡¢
87 (¸½ºß¤Î´Ý¤áÊý¸þ¤Ë´Ø·¸¤Ê¤¯) 0 ¤«¤é±ó¤¤Êý¤Ë´Ý¤á¤ë
102 .\"O .SH "RETURN VALUE"
104 .\"O These functions return the rounded integer value.
105 ¤³¤ì¤é¤Î´Ø¿ô¤Ï´Ý¤á¤¿À°¿ôÃͤòÊÖ¤¹¡£
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 ¤½¤Î¤â¤Î¤¬ÊÖ¤µ¤ì¤ë¡£
113 .\"O No errors occur.
115 .\"O POSIX.1-2001 documents a range error for overflows, but see NOTES.
116 POSIX.1-2001 ¤Ë¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ç¤ÎÈÏ°Ï¥¨¥é¡¼ (range error) ¤Î
117 µºÜ¤¬¤¢¤ë¡£¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È¡£
120 .\"O These functions first appeared in glibc in version 2.1.
121 ¤³¤ì¤é¤Î´Ø¿ô¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.1 ¤Ç½é¤á¤ÆÅо줷¤¿¡£
122 .\"O .SH "CONFORMING TO"
127 .\"O POSIX.1-2001 contains text about overflow (which might set
134 POSIX.1-2001 ¤Ë¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ë´Ø¤¹¤ëµ½Ò¤¬¤¢¤ê¡¢
135 ¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Î¾ì¹ç¤Ë¤Ï¡¢
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 ¤Ç¤¢¤ë¡£)
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
162 ´Ý¤á¤¿ÃͤòÀ°¿ô·¿¤Ë³ÊǼ¤·¤¿¾ì¹ç¤Ë¤Ï¡¢¤ª¤½¤é¤¯¤³¤Î´Ø¿ô¤Ç¤Ï¤Ê¤¯
164 ¤ËºÜ¤Ã¤Æ¤¤¤ë´Ø¿ô¤Î¤É¤ì¤«¤ò»È¤¤¤¿¤¤¤Î¤À¤í¤¦¡£