OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man7 / math_error.7
1 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
25 .\"         all rights reserved.
26 .\" Translated 2008-08-17, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.07
27 .\" 
28 .\"WORD:        significand     ²¾¿ôÉô
29 .\"WORD:        domain error    Îΰ襨¥é¡¼
30 .\"WORD:        pole error      ¶Ë¥¨¥é¡¼
31 .\"WORD:        range error     ÈÏ°Ï¥¨¥é¡¼
32 .\" 
33 .TH MATH_ERROR 7 2008-08-11 "Linux" "Linux Programmer's Manual"
34 .SH Ì¾Á°
35 math_error \- ¿ô³Ø´Ø¿ô¤«¤é¤Î¥¨¥é¡¼¤Î¸¡½Ð
36 .SH ½ñ¼°
37 .nf
38 .B #include <math.h>
39 .B #include <errno.h>
40 .B #include <fenv.h>
41 .fi
42 .SH ÀâÌÀ
43 ¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢¤Û¤È¤ó¤É¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Ï (\-1 ¤ä NULL ¤Ê¤É¤Î)
44 ÆÃÊ̤ÊÃͤòÊÖ¤¹¤³¤È¤Ç¥¨¥é¡¼¤òÄÌÃΤ¹¤ë¡£
45 .I <math.h>
46 ¤ÇÀë¸À¤µ¤ì¤Æ¤¤¤ë¿ô³Ø´Ø¿ô¤Ï¡¢Ä̾ï¤ÏÉâÆ°¾®¿ôÅÀÃͤòÊÖ¤¹¤Î¤Ç¡¢
47 ¾¤Îµ¡¹½¤ò»È¤Ã¤Æ¥¨¥é¡¼¤òÄÌÃΤ¹¤ë¡£
48 ¥¨¥é¡¼ÄÌÃε¡¹½¤Ï 2 ¼ïÎढ¤ê¡¢
49 ¸Å¤¤¤â¤Î¤¬
50 .I errno
51 ¤òÀßÄꤹ¤ë¤ä¤êÊý¤Ç¤¢¤ê¡¢¿·¤·¤¤¤â¤Î¤¬
52 .BR fenv (3)
53 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ëÉâÆ°¾®¿ôÅÀÎã³°µ¡¹½¤Ç¤¢¤ë¡£
54 .RB ( feclearexcept (3)
55 ¤È
56 .BR fetestexcept (3)
57 ¤ò»ÈÍѤ¹¤ë¡£¤³¤ì¤é¤Ë¤Ä¤¤¤Æ¤Ï°Ê²¼¤Ç³µÍפòÀâÌÀ¤·¤Æ¤¤¤ë¡£)
58
59 °Ü¿¢À­¤¬É¬Í×¤Ê¥×¥í¥°¥é¥à¤Ç¡¢¿ô³Ø´Ø¿ô¤«¤é¤Î¥¨¥é¡¼¤ò³Îǧ¤¹¤ëɬÍפ¬¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢
60 ¿ô³Ø´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë
61 .I errno
62 ¤ò 0 ¤ËÀßÄꤷ¡¢°Ê²¼¤ò¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤¢¤ë¡£
63 .in +4n
64 .nf
65
66 feclearexcept(FE_ALL_EXCEPT);
67 .fi
68 .in
69
70 ¿ô³Ø´Ø¿ô¤«¤éÊ֤äƤ­¤¿ºÝ¤Ë¡¢
71 .I errno
72 ¤¬ 0 °Ê³°¤«¡¢°Ê²¼¤Î¸Æ¤Ó½Ð¤·¤¬ 0 °Ê³°¤òÊÖ¤·¤¿¾ì¹ç
73 .RB ( fenv (3)
74 »²¾È)¡¢¿ô³Ø´Ø¿ô¤Ç¥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë¡£
75 .in +4n
76 .nf
77
78 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW |
79              FE_UNDERFLOW);
80 .fi
81 .in
82 .\" enum
83 .\" {
84 .\" FE_INVALID = 0x01,
85 .\" __FE_DENORM = 0x02,
86 .\" FE_DIVBYZERO = 0x04,
87 .\" FE_OVERFLOW = 0x08,
88 .\" FE_UNDERFLOW = 0x10,
89 .\" FE_INEXACT = 0x20
90 .\" };
91
92 ¿ô³Ø´Ø¿ô¤ÇȯÀ¸¤¹¤ë¥¨¥é¡¼¾ò·ï¤Ë¤Ä¤¤¤Æ¤Ï°Ê²¼¤ÇÀâÌÀ¤¹¤ë¡£
93 .SS Îΰ襨¥é¡¼ (domain error)
94 .I Îΰ襨¥é¡¼
95 ¤¬È¯À¸¤¹¤ë¤Î¤Ï¡¢¿ô³Ø´Ø¿ô¤ËÅϤµ¤ì¤¿°ú¤­¿ô¤ÎÃͤ¬¤½¤Î´Ø¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë
96 Îΰè¤ËÆþ¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ç¤¢¤ë (Î㤨¤Ð
97 .BR log (3)
98 ¤ËÉé¤Î°ú¤­¿ô¤òÅϤ·¤¿¾ì¹ç)¡£
99 Îΰ襨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢
100 ¿ô³Ø´Ø¿ô¤ÏÉáÄ̤ϠNaN ¤òÊÖ¤·
101 (Ʊ¤¸¾õ¶·¤Ç°ã¤¦ÃͤòÊÖ¤¹´Ø¿ô¤â¤¢¤ë)¡¢
102 .I errno
103 ¤Ë
104 .B EDOM
105 ¤òÀßÄꤷ¡¢¡Ö̵¸ú (invalid)¡×
106 ÉâÆ°¾®¿ôÅÀÎã³°
107 .RB ( FE_INVALID )
108 ¤ò¾å¤²¤ë¡£
109 .SS ¶Ë¥¨¥é¡¼ (pole error)
110 .I ¶Ë¥¨¥é¡¼
111 ¤¬È¯À¸¤¹¤ë¤Î¤Ï¡¢´Ø¿ô¤Î¿ô³ØŪ¤Ê·ë²Ì¤¬Ìµ¸ÂÂ礽¤Î¤â¤Î¤È¤Ê¤ë¾ì¹ç¤Ç¤¢¤ë
112 (Î㤨¤Ð
113 0 ¤ÎÂпô¤ÏÉé¤Î̵¸ÂÂç¤Ç¤¢¤ë)¡£
114 ¶Ë¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢¤½¤Î´Ø¿ô¤ÎÊÖ¤êÃͤϠ(Éä¹æÉÕ¤­¤Î)
115 .BR HUGE_VAL ,
116 .BR HUGE_VALF ,
117 .B HUGE_VALL
118 ¤Î¤¤¤º¤ì¤«¤È¤Ê¤ë (Á°µ­¤ÎÃͤΤ¦¤Á¤É¤ì¤¬Ê֤뤫¤Ï´Ø¿ô¤ÎÊÖ¤êÃͤη¿¤Ë¤è¤ê·è¤Þ¤ê¡¢
119 ¤½¤ì¤¾¤ì
120 .IR double ,
121 .IR float ,
122 .I "long double"
123 ¤ËÂбþ¤¹¤ë)¡£
124 ·ë²Ì¤ÎÉä¹æ¤Ï¡¢¤½¤Î´Ø¿ô¤Î¿ô³ØŪ¤ÊÄêµÁ¤«¤é·èÄꤵ¤ì¤ë¡£
125 .I errno
126 ¤Ï
127 .B ERANGE
128 ¤ËÀßÄꤵ¤ì¡¢¡Ö0 ¤Ë¤è¤ë½ü»» (divide-by-zero)¡×
129 ÉâÆ°¾®¿ôÅÀÎã³°
130 .RB ( FE_DIVBYZERO )
131 ¤¬¾å¤¬¤ë¡£
132 .SS ÈÏ°Ï¥¨¥é¡¼ (range ¥¨¥é¡¼)
133 .I ÈÏ°Ï¥¨¥é¡¼
134 ¤¬È¯À¸¤¹¤ë¤Î¤Ï¡¢´Ø¿ô¤Î·ë²Ì¤ÎÃͤ¬¤½¤Î´Ø¿ô¤ÎÊÖ¤êÃͤη¿¤Ç¤Ïɽ¸½¤Ç¤­¤Ê¤¤¾ì¹ç
135 ¤Ç¤¢¤ë¡£´Ø¿ô¤ÎÊÖ¤êÃͤϡ¢ÈÏ°Ï¥¨¥é¡¼¤¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ç¤¢¤Ã¤¿¤«¥¢¥ó¥À¡¼¥Õ¥í¡¼
136 ¤Ç¤¢¤Ã¤¿¤«¤Ë¤è¤Ã¤Æ°Û¤Ê¤ë¡£
137
138 ÉâÆ°¾®¿ôÅÀ¤Î¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Ï¡¢·ë²Ì¤¬Í­¸Â¤À¤¬¡¢Â礭²á¤®¤Æ
139 ·ë²Ì¤òÊÖ¤¹·¿¤Ç¤Ïɽ¸½¤Ç¤­¤Ê¤¤¾ì¹ç¤ËȯÀ¸¤¹¤ë¡£
140 ¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤¬È¯À¸¤¹¤ë¤È¡¢
141 ¤½¤Î´Ø¿ô¤Ï
142 .BR HUGE_VAL ,
143 .BR HUGE_VALF ,
144 .B HUGE_VALL
145 ¤Î¤¤¤º¤ì¤«¤òÊÖ¤¹ (Á°µ­¤ÎÃͤΤ¦¤Á¤É¤ì¤¬Ê֤뤫¤Ï´Ø¿ô¤ÎÊÖ¤êÃͤη¿¤Ë¤è¤ê·è¤Þ¤ê¡¢
146 ¤½¤ì¤¾¤ì
147 .IR double ,
148 .IR float ,
149 .I "long double"
150 ¤ËÂбþ¤¹¤ë)¡£
151 .I errno
152 ¤Ï
153 .B ERANGE
154 ¤ËÀßÄꤵ¤ì¡¢¡Ö¥ª¡¼¥Ð¡¼¥Õ¥í¡¼ (overflow)¡×
155 ÉâÆ°¾®¿ôÅÀÎã³°
156 .RB ( FE_OVERFLOW )
157 ¤¬¾å¤¬¤ë¡£
158
159 ÉâÆ°¾®¿ôÅÀ¤Î¥¢¥ó¥À¡¼¥Õ¥í¡¼¤Ï¡¢
160 ·ë²Ì¤¬¾®¤µ²á¤®¤Æ¡¢·ë²Ì¤òÊÖ¤¹·¿¤Ç¤Ïɽ¸½¤Ç¤­¤Ê¤¤¾ì¹ç¤ËȯÀ¸¤¹¤ë¡£
161 ¥¢¥ó¥À¡¼¥Õ¥í¡¼¤¬È¯À¸¤¹¤ë¤È¡¢¿ô³Ø´Ø¿ô¤ÏÄ̾ï¤Ï 0.0 ¤òÊÖ¤¹
162 (C99 ¤Ç¤Ï¡¢»ØÄꤵ¤ì¤¿·¿¤Ë¤ª¤¤¤ÆºÇ¾®¤ÎÀµµ¬²½¤µ¤ì¤¿Àµ¤ÎÃͤè¤êÂ礭¤¯¤Ê¤¤
163 Ãͤò»ý¤Ä¼ÂÁõÄêµÁ (implementation-defined) ¤ÎÃͤòÊÖ¤¹¡¢¤È¤Ê¤Ã¤Æ¤¤¤ë)¡£
164 .I errno
165 ¤Ï
166 .B ERANGE
167 ¤ËÀßÄꤵ¤ì¡¢¡Ö¥¢¥ó¥À¡¼¥Õ¥í¡¼¡×ÉâÆ°¾®¿ôÅÀÎã³°
168 .RB ( FE_UNDERFLOW )
169 ¤¬¾å¤¬¤ë¡£
170
171 ¤¤¤¯¤Ä¤«¤Î´Ø¿ô¤Ç¤Ï¡¢ÅϤµ¤ì¤¿°ú¤­¿ô¤ÎÃͤ䡢Àµ¤·¤¤´Ø¿ô¤Î·ë²Ì¤¬
172 .I subnormal (ÈóÀµµ¬²½¿ô)
173 ¤Ë¤Ê¤ë¾ì¹ç¤ËÈÏ°Ï¥¨¥é¡¼¤ò¾å¤²¤ë¡£
174 subnormal ¤ÊÃͤȤϡ¢0 ¤Ç¤Ï¤Ê¤¤¤¬¡¢¤½¤ÎÃͤ¬¾®¤µ¤¹¤®¤Æ
175 (²¾¿ôÉô¤ÎºÇ¾å°Ì¥Ó¥Ã¥È¤¬ 1 ¤È¤Ê¤ë) É¸½à·Á¤Ç¤Ïɽ¸½¤Ç¤­¤Ê¤¤¤è¤¦¤ÊÃͤǤ¢¤ë¡£
176 subnormal ¤ÊÃͤÎɽ¸½¤Ç¤Ï¡¢²¾¿ôÉô¤Î¾å°Ì¦¤Î¥Ó¥Ã¥È¤Ë 1 ¸Ä°Ê¾å¤Î 0 ¤¬
177 ´Þ¤Þ¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
178 .SH Ãí°Õ
179 C99 ¤È POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë
180 .I math_errhandling
181 ¼±Ê̻ҤϠglibc ¤Ç¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
182 .\" See CONFORMANCE in the glibc 2.8 (and earlier) source.
183 ¤³¤Î¼±Ê̻Ҥϡ¢2 ¤Ä¤Î¥¨¥é¡¼ÄÌÃε¡¹½
184 .RI ( errno
185 ¤È
186 .BR fetestexcept (3)
187 ·Ðͳ¤Ç¼èÆÀ¤Ç¤­¤ëÎã³°) ¤Î¤¦¤Á¤É¤Á¤é¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¤«¤òÄÌÃÎ
188 ¤¹¤ë¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
189 ɸ½à¤Ç¤Ï¡¢¾¯¤Ê¤¯¤È¤â°ì¤Ä¤Ï»ÈÍѤµ¤ì¤ë¤³¤È¤¬Í׵ᤵ¤ì¤Æ¤¤¤ë¤¬¡¢
190 ξÊý¤È¤âÍøÍѲÄǽ¤Ç¤¢¤Ã¤Æ¤â¤è¤¤¤È¤µ¤ì¤Æ¤¤¤ë¡£
191 glibc ¤Ç¤Î¸½ºß¤Î (¥Ð¡¼¥¸¥ç¥ó 2.8 ¤Ç¤Î) ¾õ¶·¤Ï¤«¤Ê¤êº®Í𤷤Ƥ¤¤ë¡£
192 ¤Û¤È¤ó¤É¤Î´Ø¿ô (¤¿¤À¤·Á´Éô¤Ç¤Ï¤Ê¤¤) ¤Ï¥¨¥é¡¼»þ¤ËÎã³°¤ò¾å¤²¤ë¡£
193 ¤¤¤¯¤Ä¤«¤Î´Ø¿ô¤Ï
194 .I errno
195 ¤âÀßÄꤹ¤ë¡£
196 .I errno
197 ¤òÀßÄꤹ¤ë¤¬¡¢Îã³°¤ò¾å¤²¤Ê¤¤´Ø¿ô¤â¾¯¤·¤À¤±Â¸ºß¤¹¤ë¡£
198 ¤É¤Á¤é¤â¹Ô¤ï¤Ê¤¤´Ø¿ô¤â¤´¤¯¾¯¿ô¤À¤¬Â¸ºß¤¹¤ë¡£
199 ¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¸Ä¡¹¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤Î¤³¤È¡£
200
201 .I errno
202 ¤È
203 .BR fetestexcept (3)
204 ¤ÎξÊý¤ò»È¤Ã¤Æ¥¨¥é¡¼¥Á¥§¥Ã¥¯¤ò¹Ô¤¦¤³¤È¤ÇÊ£»¨¤Ë¤Ê¤ë¤Î¤òÈò¤±¤ë¤¿¤á¡¢
205 ¿¤¯¤Î¾ì¹ç¡¢´Ø¿ô¸Æ¤Ó½Ð¤·¤ò¹Ô¤¦Á°¤ËÉÔÀµ¤Ê°ú¤­¿ô¤«¤Î¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
206 ÊýË¡¤¬¿ä¾©¤µ¤ì¤Æ¤¤¤ë¡£
207 .\" http://www.securecoding.cert.org/confluence/display/seccode/FLP32-C.+Prevent+or+detect+domain+and+range+errors+in+math+functions
208 Î㤨¤Ð¡¢°Ê²¼¤Î¥³¡¼¥É¤Ï¡¢
209 .BR log (3)
210 ¤Î°ú¤­¿ô¤¬ NaN ¤Ç¤â (¶Ë¥¨¥é¡¼¤È¤Ê¤ë) 0 ¤Ç¤â (Îΰ襨¥é¡¼¤È¤Ê¤ë) 0 Ì¤Ëþ
211 ¤Ç¤â¤Ê¤¤¤³¤È¤òÊݾڤ¹¤ë¤â¤Î¤Ç¤¢¤ë¡£
212 .in +4n
213 .nf
214
215 double x, r;
216
217 if (isnan(x) || islessequal(x, 0)) {
218     /* Deal with NaN / pole error / domain error */
219 }
220
221 r = log(x);
222
223 .fi
224 .in
225 ¤³¤Î¥Ú¡¼¥¸¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¤³¤È¤Ï¡¢
226 .RI ( <complex.h>
227 ¤ÇÀë¸À¤µ¤ì¤Æ¤¤¤ë) Ê£ÁÇ¿ô´Ø¿ô¤Ë¤Ï¤¢¤Æ¤Ï¤Þ¤é¤Ê¤¤¡£
228 °ìÈ̤ˡ¢C99 ¤ä POSIX.1-2001 ¤Ç¤Ï¤³¤ì¤é¤Î´Ø¿ô¤¬¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤ò
229 Í׵ᤷ¤Æ¤Ê¤¤¡£
230
231 .BR gcc (1)
232 ¤Î
233 .I "-fno-math-errno"
234 ¥ª¥×¥·¥ç¥ó¤ò»È¤¦¤È¡¢¼Â¹Ô¥Õ¥¡¥¤¥ë¤Ç¡¢É¸½à¤Î¼ÂÁõ¤è¤ê¤â¹â®¤Ê¿ô³Ø´Ø¿ô¤Î
235 ¼ÂÁõ¤¬»ÈÍѤµ¤ì¤ë¤è¤¦¤Ë¤Ê¤ë¤¬¡¢
236 ¥¨¥é¡¼»þ¤Ë
237 .I errno
238 ¤¬ÀßÄꤵ¤ì¤Ê¤¤
239 .RB ( gcc (1)
240 ¤Î
241 .I "-ffast-math"
242 ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤¿¾ì¹ç¤Ë¤â
243 .I "-fno-math-errno"
244 ¤ÏÍ­¸ú¤Ë¤Ê¤ë)¡£
245 ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤¿¾ì¹ç¤Ç¤â¡¢
246 .BR fetestexcept (3)
247 ¤ò»È¤Ã¤¿¥¨¥é¡¼¤Î¸¡ºº¤Ï²Äǽ¤Ç¤¢¤ë¡£
248 .SH ´ØÏ¢¹àÌÜ
249 .BR gcc (1),
250 .BR errno (3),
251 .BR fenv (3),
252 .BR fpclassify (3),
253 .BR INFINITY (3),
254 .BR isgreater (3),
255 .BR matherr (3),
256 .BR nan (3)
257 .br
258 .I "info libc"