OSDN Git Service

(split) Fixed #25191 (typo in fenv.3).
[linuxjm/LDP_man-pages.git] / draft / man3 / fenv.3
1 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" 2000-08-14 added GNU additions from Andreas Jaeger
24 .\" 2000-12-05 some changes inspired by acahalan's remarks
25 .\"
26 .\" Japanese Version Copyright (c) 2000-2001 NAKANO Takeo
27 .\" and Copyright (c) 2008 Akihiro MOTOKI.
28 .\" Translated 2001-02-08, NAKANO Takeo <nakano@apm.seikei.ac.jp>
29 .\" Updated 2003-10-15, Kentaro Shirakata <argrath@ub32.org>
30 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\" Updated 2008-09-16, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
32 .\"
33 .\"WORD:        (floating-point) exception      (ÉâÆ°¾®¿ôÅÀ) Îã³°
34 .\"WORD:        rounding                        ´Ý¤á
35 .\"WORD:        opaque                          ÆâÉô¤Î
36 .\"
37 .TH FENV 3  2010-10-31 "Linux" "Linux Programmer's Manual"
38 .\"O .SH NAME
39 .SH Ì¾Á°
40 .\"O feclearexcept, fegetexceptflag, feraiseexcept, fesetexceptflag,
41 .\"O fetestexcept, fegetenv, fegetround, feholdexcept, fesetround,
42 .\"O fesetenv, feupdateenv, feenableexcept, fedisableexcept,
43 .\"O fegetexcept \- floating-point rounding and exception handling
44 feclearexcept, fegetexceptflag, feraiseexcept, fesetexceptflag,
45 fetestexcept, fegetenv, fegetround, feholdexcept, fesetround,
46 fesetenv, feupdateenv, feenableexcept, fedisableexcept,
47 fegetexcept \- ÉâÆ°¾®¿ôÅÀ¤Î´Ý¤á¤ÈÎã³°¤Î¼è¤ê°·¤¤
48 .\"O .SH SYNOPSIS
49 .SH ½ñ¼°
50 .nf
51 .B #include <fenv.h>
52 .sp
53 .BI "int feclearexcept(int " excepts );
54 .br
55 .BI "int fegetexceptflag(fexcept_t *" flagp ", int " excepts );
56 .br
57 .BI "int feraiseexcept(int " excepts );
58 .br
59 .BI "int fesetexceptflag(const fexcept_t *" flagp ", int " excepts );
60 .br
61 .BI "int fetestexcept(int " excepts );
62 .sp
63 .B "int fegetround(void);"
64 .br
65 .BI "int fesetround(int " rounding_mode );
66 .sp
67 .BI "int fegetenv(fenv_t *" envp );
68 .br
69 .BI "int feholdexcept(fenv_t *" envp );
70 .br
71 .BI "int fesetenv(const fenv_t *" envp );
72 .br
73 .BI "int feupdateenv(const fenv_t *" envp );
74 .fi
75 .sp
76 .\"O Link with \fI\-lm\fP.
77 \fI\-lm\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
78 .\"O .SH DESCRIPTION
79 .SH ÀâÌÀ
80 .\"O These eleven functions were defined in C99, and describe the handling
81 .\"O of floating-point rounding and exceptions (overflow, zero-divide etc.).
82 ¤³¤ì¤é¤Î 11 ¸Ä¤Î´Ø¿ô¤Ï C99 ¤ÇÄêµÁ¤µ¤ì¤Æ¤ª¤ê¡¢
83 ÉâÆ°¾®¿ôÅÀ¤Î´Ý¤á¤ÈÎã³° (¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¡¢¥¼¥í¤Ë¤è¤ë½ü»»¤Ê¤É)
84 ¤Î¼è¤ê°·¤¤¤òµ¬Äꤹ¤ë¡£
85 .\"O .SS Exceptions
86 .SS Îã³°
87 .\"O The
88 .\"O .I divide-by-zero
89 .\"O exception occurs when an operation on finite numbers
90 .\"O produces infinity as exact answer.
91 .I divide-by-zero
92 Îã³°¤Ï¡¢Í­¸Â¤Î¿ôÃͤËÂФ¹¤ë±é»»¤¬¡¢
93 ̵¸ÂÂç¤ÎÅú¤¨¤òÀ¸À®¤¹¤ë¤è¤¦¤Ê¾ì¹ç¤Ëµ¯¤³¤ë¡£
94 .LP
95 .\"O The
96 .\"O .I overflow
97 .\"O exception occurs when a result has to be represented as a
98 .\"O floating-point number, but has (much) larger absolute value than the
99 .\"O largest (finite) floating-point number that is representable.
100 .I overflow
101 Îã³°¤Ï¡¢·ë²Ì¤¬ÉâÆ°¾®¿ôÅÀ¿ôÃͤÇɽµ­¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ë¡¢
102 ¤½¤ÎÀäÂÐÃͤ¬É½¸½²Äǽ¤ÊÉâÆ°¾®¿ôÅÀ¿ô¤Î (Í­¸Â¤Î) ºÇÂçÃͤè¤ê¤â
103 (¤º¤Ã¤È) Â礭¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¦¤è¤¦¤Ê¾ì¹ç¤Ëµ¯¤³¤ë¡£
104 .LP
105 .\"O The
106 .\"O .I underflow
107 .\"O exception occurs when a result has to be represented as a
108 .\"O floating-point number, but has smaller absolute value than the smallest
109 .\"O positive normalized floating-point number (and would lose much accuracy
110 .\"O when represented as a denormalized number).
111 .I underflow
112 Îã³°¤Ï¡¢·ë²Ì¤¬ÉâÆ°¾®¿ôÅÀ¿ôÃͤÇɽµ­¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤Î¤Ë¡¢
113 ¤½¤ÎÀäÂÐÃͤ¬Àµ¤ÎÀµµ¬²½ÉâÆ°¾®¿ôÅÀ¿ô¤ÎºÇ¾®Ãͤè¤ê¤â
114 ¾®¤µ¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¦
115 (¤½¤·¤Æ ÈóÀµµ¬²½¿ô¤Çɽ¸½¤·¤¿¾ì¹ç¤ËÈó¾ï¤ËÀºÅÙ¤ò¼º¤Ã¤Æ¤·¤Þ¤¦)
116 ¤è¤¦¤Ê¾ì¹ç¤Ëµ¯¤³¤ë¡£
117 .LP
118 .\"O The
119 .\"O .I inexact
120 .\"O exception occurs when the rounded result of an operation
121 .\"O is not equal to the infinite precision result.
122 .\"O It may occur whenever
123 .\"O .I overflow
124 .\"O or
125 .\"O .I underflow
126 .\"O occurs.
127 .I inexact
128 Îã³°¤Ï¡¢´Ý¤á¸å¤Î±é»»·ë²Ì¤¬¡¢
129 ̵¸ÂÀºÅ٤ηë²Ì¤È°Û¤Ê¤ë¤è¤¦¤Ê¾ì¹ç¤Ëµ¯¤³¤ë¡£
130 .I overflow
131 Îã³°¤«
132 .I underflow
133 Îã³°¤¬µ¯¤­¤¿¤È¤­¤Ë¤Ï¡¢¾ï¤Ë¤³¤ÎÎã³°¤âµ¯¤³¤ë¡£
134 .LP
135 .\"O The
136 .\"O .I invalid
137 .\"O exception occurs when there is no well-defined result
138 .\"O for an operation, as for 0/0 or infinity \- infinity or sqrt(\-1).
139 .I invalid
140 Îã³°¤Ï¡¢±é»»·ë²Ì¤¬¤¦¤Þ¤¯ÄêµÁ¤Ç¤­¤Ê¤¤·ë²Ì¤òÀ¸¤¸¤ë¤è¤¦¤Ê¾ì¹ç¤Ëµ¯¤³¤ë¡£
141 Î㤨¤Ð 0/0¡¢Ìµ¸ÂÂç \- Ìµ¸ÂÂç¡¢sqrt(\-1) ¤Ê¤É¡£
142 .\"O .SS "Exception handling"
143 .SS Îã³°½èÍý
144 .\"O Exceptions are represented in two ways: as a single bit
145 .\"O (exception present/absent), and these bits correspond in some
146 .\"O implementation-defined way with bit positions in an integer,
147 .\"O and also as an opaque structure that may contain more information
148 .\"O about the exception (perhaps the code address where it occurred).
149 Îã³°¤Îɽ¤·Êý¤Ë¤Ï 2 ¤Ä¤ÎÊýË¡¤¬¤¢¤ë¡£
150 ¤Ò¤È¤Ä¤Ï¡¢Ã±°ì¤Î¥Ó¥Ã¥È¤Ç (Îã³°¤¬¤¢¤Ã¤¿¤«¤Ê¤«¤Ã¤¿¤«¤ò) É½¤¹ÊýË¡¤Ç¡¢
151 ¤³¤ì¤é¤Î¥Ó¥Ã¥È¤ÏÀ°¿ô¤Î¤¢¤ë¥Ó¥Ã¥È°ÌÃÖ¤ËÂбþ¤·¡¢¥Ó¥Ã¥È¤ÎÂбþÉÕ¤±¤Ï
152 ¼ÂÁõ°Í¸¤Ç¤¢¤ë¡£¤â¤¦°ì¤Ä¤Ï¡¢ÆâÉô¹½Â¤ÂΤò»È¤Ã¤Æɽ¤¹ÊýË¡¤Ç¡¢
153 ¤³¤ÎÊýË¡¤ÎÊý¤¬Îã³°¤Ë´Ø¤¹¤ë¤è¤ê¿¤¯¤Î¾ðÊó
154 (Î㤨¤ÐÎã³°¤¬µ¯¤³¤Ã¤¿¥³¡¼¥É¤Î¥¢¥É¥ì¥¹¤Ê¤É) ¤¬´Þ¤Þ¤ì¤ë¡£
155 .LP
156 .\"O Each of the macros
157 .\"O .BR FE_DIVBYZERO ,
158 .\"O .BR FE_INEXACT ,
159 .\"O .BR FE_INVALID ,
160 .\"O .BR FE_OVERFLOW ,
161 .\"O .B FE_UNDERFLOW
162 .\"O is defined when the implementation supports handling
163 .\"O of the corresponding exception, and if so then
164 .\"O defines the corresponding bit(s), so that one can call
165 .\"O exception handling functions, for example, using the integer argument
166 .\"O .BR FE_OVERFLOW | FE_UNDERFLOW .
167 .\"O Other exceptions may be supported.
168 .\"O The macro
169 .\"O .B FE_ALL_EXCEPT
170 .\"O is the bitwise OR of all bits corresponding to supported exceptions.
171 .BR FE_DIVBYZERO ,
172 .BR FE_INEXACT ,
173 .BR FE_INVALID ,
174 .BR FE_OVERFLOW ,
175 .B FE_UNDERFLOW
176 ¤Î³Æ¥Þ¥¯¥í¤Ï¡¢¤½¤ì¤¾¤ìÂбþ¤¹¤ëÎã³°¤Î½èÍý¤ò
177 ¼ÂÁõ¤¬¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¾ì¹ç¤ËÄêµÁ¤µ¤ì¤ë¡£
178 ¤³¤Î¤È¤­Âбþ¤¹¤ë¥Ó¥Ã¥È¤ò¤½¤ì¤¾¤ìÄêµÁ¤¹¤ë¤³¤È¤Ë¤Ê¤ë¤Î¤Ç¡¢
179 Îã³°½èÍý´Ø¿ô¤Î¸Æ¤Ó½Ð¤·¤ò¡¢Î㤨¤Ð
180 .BR FE_OVERFLOW | FE_UNDERFLOW
181 ¤È¤¤¤¦À°¿ô¤Î°ú¤­¿ô¤òÍѤ¤¤Æ¹Ô¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
182 ¾¤ÎÎã³°¤â¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
183 .B FE_ALL_EXCEPT
184 ¥Þ¥¯¥í¤Ï¡¢¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ëÎã³°¤ËÂбþ¤¹¤ë¥Ó¥Ã¥È¤¬Á´¤Æ¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë
185 (¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ëÎã³°Á´¤Æ¤ÎÏÀÍýϤǤ¢¤ë)¡£
186 .PP
187 .\"O The
188 .\"O .BR feclearexcept ()
189 .\"O function clears the supported exceptions represented by the bits
190 .\"O in its argument.
191 .BR feclearexcept ()
192 ´Ø¿ô¤Ï¡¢°ú¤­¿ô
193 .I excepts
194 ¤Î¥Ó¥Ã¥ÈÎó¤Ç»ØÄꤵ¤ì¤¿Îã³°¤ò¥¯¥ê¥¢¤¹¤ë
195 (½èÍý¤Ï¼ÂÁõ¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ëÎã³°¤Ë¤Ä¤¤¤Æ¤Î¤ß¹Ô¤ï¤ì¤ë)¡£
196 .LP
197 .\"O The
198 .\"O .BR fegetexceptflag ()
199 .\"O function stores a representation of the state of the exception flags
200 .\"O represented by the argument
201 .\"O .I excepts
202 .\"O in the opaque object
203 .\"O .IR *flagp .
204 .BR fegetexceptflag ()
205 ´Ø¿ô¤Ï¡¢°ú¤­¿ô
206 .I excepts
207 ¤Ç»ØÄꤵ¤ì¤¿Îã³°¥Õ¥é¥°¤Î¾õÂÖ¤ò
208 .I *flagp
209 ¤¬»Ø¤¹ÆâÉô¥ª¥Ö¥¸¥§¥¯¥È¤ËÊݸ¤¹¤ë¡£
210 .LP
211 .\"O The
212 .\"O .BR feraiseexcept ()
213 .\"O function raises the supported exceptions represented by the bits in
214 .\"O .IR excepts .
215 .BR feraiseexcept ()
216 ´Ø¿ô¤Ï¡¢
217 .I excepts
218 ¤Î¥Ó¥Ã¥ÈÎó¤Ç»ØÄꤵ¤ì¤¿Îã³°¤Î¤¦¤Á¡¢
219 ¼ÂÁõ¤¬¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¤â¤Î¤òȯÀ¸¤µ¤»¤ë¡£
220 .LP
221 .\"O The
222 .\"O .BR fesetexceptflag ()
223 .\"O function sets the complete status for the exceptions represented by
224 .\"O .I excepts
225 .\"O to the value
226 .\"O .IR *flagp .
227 .\"O This value must have been obtained by an earlier call of
228 .\"O .BR fegetexceptflag ()
229 .\"O with a last argument that contained all bits in
230 .\"O .IR excepts .
231 .BR fesetexceptflag ()
232 ´Ø¿ô¤Ï¡¢
233 .I excepts
234 ¤Ç»ØÄꤵ¤ì¤¿Îã³°¤ËÂбþ¤¹¤ë¥Õ¥é¥°¤Î¾õÂÖ¤ò
235 .I *flagp
236 ¤ÎÃͤËÀßÄꤹ¤ë¡£
237 .I *flagp
238 ¤ÎÃͤϡ¢¤³¤Î´Ø¿ô¤ò¸Æ¤ÖÁ°¤Ë
239 .BR fegetexceptflag ()
240 ´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤Æ¼èÆÀ¤·¤Æ¤ª¤«¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
241 (¤³¤Î¤È¤­¡¢
242 .BR fegetexceptflag ()
243 ¤ÎºÇ¸å¤Î°ú¤­¿ô¤Ë¤Ï¡¢
244 .BR fesetexceptflag ()
245 ¤ËÅϤ¹
246 .I excepts
247 ¤Î¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¤ò´Þ¤àÃͤò»ØÄꤹ¤ë¤³¤È)¡£
248 .LP
249 .\"O The
250 .\"O .BR fetestexcept ()
251 .\"O function returns a word in which the bits are set that were
252 .\"O set in the argument
253 .\"O .I excepts
254 .\"O and for which the corresponding exception is currently set.
255 .BR fetestexcept ()
256 ´Ø¿ô¤Ï¡¢
257 .I excepts
258 °ú¤­¿ô¤Ç¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¥Ó¥Ã¥È¤Î¤¦¤Á¡¢
259 ¸½ºßÀßÄꤵ¤ì¤Æ¤¤¤ëÎã³°¤ËÂбþ¤¹¤ë¥Ó¥Ã¥È¤¬ 1 ¤Ë¤Ê¤Ã¤¿¥ï¡¼¥É¤òÊÖ¤¹¡£
260 .\"O .SS Rounding mode
261 .SS ´Ý¤á¥â¡¼¥É
262 .\"O The rounding mode determines how the result of floating-point operations
263 .\"O is treated when the result cannot be exactly represented in the significand.
264 .\"O Various rounding modes may be provided:
265 .\"O round to nearest (the default),
266 .\"O round up (toward positive infinity),
267 .\"O round down (toward negative infinity), and
268 .\"O round toward zero.
269 ´Ý¤á¥â¡¼¥É¤Ï¡¢·ë²Ì¤¬²¾¿ôÉô¤À¤±¤ÇÀµ³Î¤Ëɽ¸½¤Ç¤­¤Ê¤¤ºÝ¤Ë¡¢
270 ÉâÆ°¾®¿ôÅÀÁàºî¤Î·ë²Ì¤ò¤É¤Î¤è¤¦¤Ë°·¤¦¤«¤ò·è¤á¤ë¤â¤Î¤Ç¤¢¤ë¡£
271 ¤µ¤Þ¤¶¤Þ¤Ê´Ý¤á¥â¡¼¥É¤òÄ󶡤¹¤ë¤³¤È¤¬¤Ç¤­¤ë:
272 ºÇ¤â¶á¤¤Ãͤ˴ݤá¤ë (¥Ç¥Õ¥©¥ë¥È)¡¢
273 (Àµ¤Î̵¸ÂÂç¤Ë¸þ¤«¤Ã¤Æ) Â礭¤¯¤Ê¤ëÊý¸þ¤Ë´Ý¤á¤ë¡¢
274 (Éé¤Î̵¸ÂÂç¤Ë¸þ¤«¤Ã¤Æ) ¾®¤µ¤¯¤Ê¤ëÊý¸þ¤Ë´Ý¤á¤ë¡¢
275 0 ¤Ë¸þ¤±¤Æ´Ý¤á¤ë¡¢¤Ç¤¢¤ë¡£
276
277 .\"O Each of the macros
278 .\"O .BR FE_TONEAREST ,
279 .\"O .BR FE_UPWARD ,
280 .\"O .BR FE_DOWNWARD ,
281 .\"O and
282 .\"O .BR FE_TOWARDZERO
283 .\"O is defined when the implementation supports getting and setting
284 .\"O the corresponding rounding direction.
285 .BR FE_TONEAREST ,
286 .BR FE_UPWARD ,
287 .BR FE_DOWNWARD ,
288 .BR FE_TOWARDZERO
289 ¤Î³Æ¥Þ¥¯¥í¤Ï¡¢¤½¤ì¤¾¤ìÂбþ¤¹¤ë´Ý¤á¤ÎÊý¸þ¤ò
290 ¼ÂÁõ¤¬¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¾ì¹ç¤ËÄêµÁ¤µ¤ì¤ë¡£
291 .LP
292 .\"O The
293 .\"O .BR fegetround ()
294 .\"O function returns the macro corresponding to the current
295 .\"O rounding mode.
296 .BR fegetround ()
297 ´Ø¿ô¤Ï¸½ºß¤Î´Ý¤á¥â¡¼¥É¤ËÂбþ¤¹¤ë¥Þ¥¯¥í¤òÊÖ¤¹¡£
298 .LP
299 .\"O The
300 .\"O .BR fesetround ()
301 .\"O function sets the rounding mode as specified by its argument
302 .\"O and returns zero when it was successful.
303 .BR fesetround ()
304 ´Ø¿ô¤Ï´Ý¤á¥â¡¼¥É¤ò°ú¤­¿ô¤ËÍ¿¤¨¤é¤ì¤¿Ãͤˤ·¡¢
305 À®¸ù¤·¤¿¤é¥¼¥í¤òÊÖ¤¹¡£
306
307 .\"O C99 and POSIX.1-2008 specify an identifier,
308 .\"O .BR FLT_ROUNDS ,
309 .\"O defined in
310 .\"O .IR <float.h> ,
311 .\"O which indicates the implementation-defined rounding
312 .\"O behavior for floating-point addition.
313 .\"O This identifier has one of the following values:
314 C99 ¤È POSIX.1-2008 ¤Ç¤Ï
315 .B FLT_ROUNDS
316 ¤È¤¤¤¦¼±Ê̻Ҥ¬µ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢
317 .I <float.h>
318 ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£¤³¤Î¼±Ê̻ҤÏ
319 ÉâÆ°¾®¿ôÅÀ¿ô¤Î²Ã»»¤Ë¤Ä¤¤¤Æ¤Î¼ÂÁõÄêµÁ¤µ¤ì¤¿´Ý¤áÆ°ºî¤òɽ¤·¡¢
320 °Ê²¼¤Î¤¤¤º¤ì¤«¤ÎÃͤò»ý¤Ä¡£
321 .IP \-1
322 .\"O The rounding mode is not determinable.
323 ´Ý¤á¥â¡¼¥É¤Ï·è¤á¤é¤ì¤Æ¤¤¤Ê¤¤¡£
324 .IP 0
325 .\"O Rounding is toward 0.
326 0 ¤Ë¸þ¤±¤Æ´Ý¤á¤ë¡£
327 .IP 1
328 .\"O Rounding is toward nearest number.
329 ºÇ¤â¶á¤¤¿ô¤Ë´Ý¤á¤ë¡£
330 .IP 2
331 .\"O Rounding is toward positive infinity.
332 Àµ¤Î̵¸ÂÂç¤Ë¸þ¤±¤Æ´Ý¤á¤ë¡£
333 .IP 3
334 .\"O Rounding is toward negative infinity.
335 Éé¤Î̵¸ÂÂç¤Ë¸þ¤±¤Æ´Ý¤á¤ë¡£
336 .PP
337 .\"O Other values represent machine-dependent, nonstandard rounding modes.
338 ¾¤ÎÃͤϥޥ·¥ó°Í¸¤Ç¤¢¤ê¡¢É¸½àŪ¤Ç¤Ï¤Ê¤¤´Ý¤á¥â¡¼¥É¤Ç¤¢¤ë¡£
339 .PP
340 .\"O The value of
341 .\"O .BR FLT_ROUNDS
342 .\"O should reflect the current rounding mode as set by
343 .\"O .BR fesetround ()
344 .\"O (but see BUGS).
345 .BR FLT_ROUNDS
346 ¤ÎÃͤˤϡ¢
347 .BR fesetround ()
348 ¤ÇÀßÄꤵ¤ì¤¿¸½ºß¤Î´Ý¤á¥â¡¼¥É¤¬È¿±Ç¤µ¤ì¤ë¤Ù¤­¤Ç¤¢¤ë
349 (⤷¡¢¡Ö¥Ð¥°¡×¤ÎÀá¤ò»²¾È)¡£
350 .\"O .SS "Floating-point environment"
351 .SS ÉâÆ°¾®¿ôÅÀ´ØÏ¢¤Î´Ä¶­
352 .\"O The entire floating-point environment, including
353 .\"O control modes and status flags, can be handled
354 .\"O as one opaque object, of type
355 .\"O .IR fenv_t .
356 .\"O The default environment is denoted by
357 .\"O .B FE_DFL_ENV
358 .\"O (of type
359 .\"O .IR "const fenv_t *" ).
360 ÉâÆ°¾®¿ôÅÀ´ØÏ¢¤Î´Ä¶­¤ÎÁ´ÂΤϡ¢
361 À©¸æ¥â¡¼¥É¤ä¾õÂ֥ե饰¤â´Þ¤á¡¢
362 .I fenv_t
363 ·¿¤ÎÆâÉô¥ª¥Ö¥¸¥§¥¯¥È°ì¤Ä¤Ç¼è¤ê°·¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
364 ¥Ç¥Õ¥©¥ë¥È¤Î´Ä¶­¤Ï¡¢
365 .RI ( "const fenv_t *"
366 ·¿¤Î)
367 .B FE_DFL_ENV
368 ¤Ç¼¨¤µ¤ì¤ë¤â¤Î¤Ç¤¢¤ë¡£
369 .\"O This is the environment setup at program start and it is defined by
370 .\"O ISO C to have round to nearest, all exceptions cleared and a nonstop
371 .\"O (continue on exceptions) mode.
372 ¤³¤ì¤Ï¥×¥í¥°¥é¥à¤Î³«»Ï»þ¤Ë¹½ÃÛ¤µ¤ì¤ë´Ä¶­¤Ç¤¢¤ê¡¢
373 ISO C ¤Ç¤Ï¡¢´Ý¤á¥â¡¼¥É¤òºÇ¤â¶á¤¤Ãͤؤδݤá
374 .RB ( FE_TONEAREST )
375 ¤ËÀßÄꤷ¡¢¤¹¤Ù¤Æ¤ÎÎã³°¤ò¥¯¥ê¥¢¤·¡¢ÉÔÄä»ß (nonstop)
376 (Îã³°¤¬µ¯¤­¤Æ¤â·Ñ³¤¹¤ë) ¥â¡¼¥É¤È¤¹¤ë¤è¤¦¤Ëµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
377 .LP
378 .\"O The
379 .\"O .BR fegetenv ()
380 .\"O function saves the current floating-point environment in the object
381 .\"O .IR *envp .
382 .BR fegetenv ()
383 ´Ø¿ô¤Ï¡¢¸½ºß¤ÎÉâÆ°¾®¿ôÅÀ´Ä¶­¤ò¡¢¥ª¥Ö¥¸¥§¥¯¥È
384 .I *envp
385 ¤ËÊݸ¤¹¤ë¡£
386 .LP
387 .\"O The
388 .\"O .BR feholdexcept ()
389 .\"O function does the same, then clears all exception flags,
390 .\"O and sets a nonstop (continue on exceptions) mode,
391 .\"O if available.
392 .\"O It returns zero when successful.
393 .BR feholdexcept ()
394 ´Ø¿ô¤âƱ¤¸Æ°ºî¤ò¹Ô¤¤¡¢
395 ¤µ¤é¤Ë²Äǽ¤Ç¤¢¤ì¤Ð¡¢Á´¤Æ¤ÎÎã³°¥Õ¥é¥°¤ò¥¯¥ê¥¢¤·¡¢
396 nonstop (Îã³°»þ¤Ë¤â¼Â¹Ô¤ò·Ñ³) ¥â¡¼¥É¤ËÀßÄꤹ¤ë¡£
397 .LP
398 .\"O The
399 .\"O .BR fesetenv ()
400 .\"O function restores the floating-point environment from
401 .\"O the object
402 .\"O .IR *envp .
403 .\"O This object must be known to be valid, for example, the result of a call to
404 .\"O .BR fegetenv ()
405 .\"O or
406 .\"O .BR feholdexcept ()
407 .\"O or equal to
408 .\"O .BR FE_DFL_ENV .
409 .\"O This call does not raise exceptions.
410 .BR fesetenv ()
411 ´Ø¿ô¤Ï¡¢ÉâÆ°¾®¿ôÅÀ´Ä¶­¤ò¡¢¥ª¥Ö¥¸¥§¥¯¥È
412 .I *envp
413 ¤«¤é¼è¤ê½Ð¤·¤¿ÃͤËÌ᤹¡£
414 ¤³¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢Í­¸ú¤Ç¤¢¤ë¤³¤È¤¬»öÁ°¤Ëʬ¤«¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
415 Î㤨¤Ð¡¢
416 .BR fegetenv ()
417 ¤ä
418 .BR feholdexcept ()
419 ¤ò¸Æ¤Ó½Ð¤·¤¿·ë²Ì¤Ç¤¢¤ë¤È¤«¡¢
420 .B FE_DFL_ENV
421 ¤ËÅù¤·¤¤¤È¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
422 ¤³¤Î´Ø¿ô¤Î¸Æ¤Ó½Ð¤·¤ÏÎã³°¤òȯÀ¸¤·¤Ê¤¤¡£
423 .LP
424 .\"O The
425 .\"O .BR feupdateenv ()
426 .\"O function installs the floating-point environment represented by
427 .\"O the object
428 .\"O .IR *envp ,
429 .\"O except that currently raised exceptions are not cleared.
430 .\"O After calling this function, the raised exceptions will be a bitwise OR
431 .\"O of those previously set with those in
432 .\"O .IR *envp .
433 .\"O As before, the object
434 .\"O .I *envp
435 .\"O must be known to be valid.
436 .BR feupdateenv ()
437 ´Ø¿ô¤Ï¡¢¥ª¥Ö¥¸¥§¥¯¥È
438 .I *envp
439 ¤¬É½¸½¤¹¤ëÉâÆ°¾®¿ôÅÀ´Ä¶­¤ò¥¤¥ó¥¹¥È¡¼¥ë¤¹¤ë¡£
440 ¤¿¤À¤·¡¢¸½ºßȯÀ¸¤·¤Æ¤¤¤ëÎã³°¤Ï¥¯¥ê¥¢¤µ¤ì¤Ê¤¤¡£
441 ¤³¤Î´Ø¿ô¤ò¸Æ¤ó¤À¸å¤ËΩ¤Ã¤Æ¤¤¤ëÎã³°¤Ï¡¢
442 ´Ø¿ô¤ò¸Æ¤ÖÁ°¤ÎÃͤÈ
443 .I *envp
444 ¤ÎÃͤȤΥӥåȤ´¤È¤Î OR ¤ò¼è¤Ã¤¿¤â¤Î¤Ë¤Ê¤ë¡£
445 ¾åµ­¤ÈƱÍͤˡ¢¥ª¥Ö¥¸¥§¥¯¥È
446 .I *envp
447 ¤Ï¡¢»öÁ°¤ËÍ­¸ú¤Ç¤¢¤ë¤³¤È¤¬Ê¬¤«¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
448 .\"O .SH "RETURN VALUE"
449 .SH ÊÖ¤êÃÍ
450 .\"O These functions return zero on success and nonzero if an error occurred.
451 .\"O .\" Earlier seven of these functions were listed as returning void.
452 .\"O .\" This was corrected in Corrigendum 1 (ISO/IEC 9899:1999/Cor.1:2001(E))
453 .\"O .\" of the C99 Standard.
454 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢À®¸ù¤Î¾ì¹ç 0 ¤òÊÖ¤·¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È 0 °Ê³°¤òÊÖ¤¹¡£
455 .\" °ÊÁ°¤Ï¡¢¤³¤ì¤é¤Î´Ø¿ô¤Î¤¦¤Á 7¤Ä¤Ï void ¤òÊÖ¤¹¤â¤Î¤È½ñ¤«¤ì¤Æ¤¤¤¿¡£
456 .\" ¤³¤ì¤Ï C99 É¸½à¤Î Corrigendum 1 (ISO/IEC 9899:1999/Cor.1:2001(E))
457 .\" ¤Ç½¤Àµ¤µ¤ì¤¿¡£
458 .\"O .SH VERSIONS
459 .SH ¥Ð¡¼¥¸¥ç¥ó
460 .\"O These functions first appeared in glibc in version 2.1.
461 ¤³¤ì¤é¤Î´Ø¿ô¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.1 ¤Ç½é¤á¤ÆÅо줷¤¿¡£
462 .\"O .SH "CONFORMING TO"
463 .SH ½àµò
464 IEC 60559 (IEC 559:1989), ANSI/IEEE 854, C99, POSIX.1-2001.
465 .\"O .SH NOTES
466 .SH Ãí°Õ
467 .\"O .SS Glibc Notes
468 .SS glibc ¤Ç¤ÎÃí°Õ
469 .\"O If possible, the GNU C Library defines a macro
470 .\"O .B FE_NOMASK_ENV
471 .\"O which represents an environment where every exception raised causes a
472 .\"O trap to occur.
473 .\"O You can test for this macro using
474 .\"O .BR #ifdef .
475 .\"O It is only defined if
476 .\"O .B _GNU_SOURCE
477 .\"O is defined.
478 ²Äǽ¤Ê¾ì¹ç¤Ë¤Ï¡¢GNU C Library ¤Ï¥Þ¥¯¥í
479 .B FE_NOMASK_ENV
480 ¤òÄêµÁ¤¹¤ë¡£¤³¤Î¥Þ¥¯¥í¤Ï¤¹¤Ù¤Æ¤ÎÎã³°¤Ç¥È¥é¥Ã¥×¤¬À¸¤¸¤ë¤è¤¦¤Ê´Ä¶­¤òɽ¤¹¡£
481 .B #ifdef
482 ¤ò»È¤Ã¤Æ¤³¤Î¥Þ¥¯¥í¤ò¥Æ¥¹¥È¤Ç¤­¤ë¡£¤³¤ì¤Ï
483 .B _GNU_SOURCE
484 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¸Â¤Ã¤ÆÄêµÁ¤µ¤ì¤ë¡£
485 .\"O The C99 standard does not define a way to set individual bits in the
486 .\"O floating-point mask, for example, to trap on specific flags.
487 .\"O Since version 2.2, glibc supports the functions
488 .\"O .BR feenableexcept ()
489 .\"O and
490 .\"O .BR fedisableexcept ()
491 .\"O to set individual floating-point traps, and
492 .\"O .BR fegetexcept ()
493 .\"O to query the state.
494 C99 É¸½à¤ÏÉâÆ°¾®¿ôÅÀ¥Þ¥¹¥¯ (Î㤨¤ÐÆÃÄê¤Î¥Õ¥é¥°¤Ç¤Î¥È¥é¥Ã¥×¤Ê¤É)
495 ¤Î³Æ¥Ó¥Ã¥È¤ÎÀßÄêÊýË¡¤Ë¤Ä¤¤¤Æ¤ÏÄêµÁ¤·¤Æ¤¤¤Ê¤¤¡£
496 ¥Ð¡¼¥¸¥ç¥ó 2.2 °Ê¹ß¤Î glibc ¤Ï¡¢
497 .BR feenableexcept ()
498 ´Ø¿ô¤È
499 .BR fedisableexcept ()
500 ´Ø¿ô¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤ª¤ê¡¢
501 ³Æ¡¹¤ÎÉâÆ°¾®¿ôÅÀ¥È¥é¥Ã¥×¤òÀßÄê¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
502 ¤Þ¤¿
503 .BR fegetexcept ()
504 ¤Ë¤è¤Ã¤Æ¾õÂÖ¤ÎÌ䤤¹ç¤ï¤»¤â¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
505 .sp
506 .nf
507 .\"O .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
508 .BR "#define _GNU_SOURCE" "         /* feature_test_macros(7) »²¾È */"
509 .B "#define _GNU_SOURCE"
510 .br
511 .B "#include <fenv.h>"
512 .sp
513 .BI "int feenableexcept(int " excepts );
514 .br
515 .BI "int fedisableexcept(int " excepts );
516 .br
517 .B "int fegetexcept(void);"
518 .br
519 .fi
520 .LP
521 .\"O The
522 .\"O .BR feenableexcept ()
523 .\"O and
524 .\"O .BR fedisableexcept ()
525 .\"O functions enable (disable) traps for each of the exceptions represented by
526 .\"O .I excepts
527 .\"O and return the previous set of enabled exceptions when successful,
528 .\"O and \-1 otherwise.
529 .\"O The
530 .\"O .BR fegetexcept ()
531 .\"O function returns the set of all currently enabled exceptions.
532 .BR feenableexcept ()
533 ´Ø¿ô¤È
534 .BR fedisableexcept ()
535 ´Ø¿ô¤Ï
536 .I excepts
537 ¤Ë¤è¤Ã¤Æɽ¸½¤µ¤ì¤ë³ÆÎã³°¤Î¥È¥é¥Ã¥×¤òÍ­¸ú (̵¸ú) ¤Ë¤¹¤ë¡£
538 À®¸ù¤·¤¿¾ì¹ç¤ÏľÁ°¤ËÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤¿Îã³°¤Î¥»¥Ã¥È¤òÊÖ¤¹¡£
539 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï \-1 ¤òÊÖ¤¹¡£
540 .BR fegetexcept ()
541 ´Ø¿ô¤Ï¸½ºßÍ­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ëÎã³°Á´¤Æ¤«¤é¤Ê¤ë¥»¥Ã¥È¤òÊÖ¤¹¡£
542 .\"O .SH BUGS
543 .SH ¥Ð¥°
544 .\"O C99 specifies that the value of
545 .\"O .B FLT_ROUNDS
546 .\"O should reflect changes to the current rounding mode, as set by
547 .\"O .BR fesetround ().
548 C99 ¤Îµ¬Äê¤Ç¤Ï¡¢
549 .BR FLT_ROUNDS
550 ¤ÎÃͤˤÏ
551 .BR fesetround ()
552 ¤ÇÀßÄꤵ¤ì¤¿¸½ºß¤Î´Ý¤á¥â¡¼¥É¤¬È¿±Ç¤µ¤ì¤ë¤Ù¤­¤Ç¤¢¤ë¤È¤µ¤ì¤Æ¤¤¤ë¡£
553 .\"O Currently,
554 ¸½ºß¤Î¤È¤³¤í¡¢
555 .\" Aug 08, glibc 2.8
556 .\"O this does not occur:
557 .\"O .B FLT_ROUNDS
558 .\"O always has the value 1.
559 ¤³¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤ª¤é¤º¡¢
560 .B FLT_ROUNDS
561 ¤Ï¾ï¤ËÃÍ 1 ¤È¤Ê¤ë¡£
562 .\" See http://gcc.gnu.org/ml/gcc/2002-02/msg01535.html
563 .\"O .SH "SEE ALSO"
564 .SH ´ØÏ¢¹àÌÜ
565 .BR math_error (7)