File: math_error.7

package info (click to toggle)
manpages-ja 0.5.0.0.20100315-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 21,156 kB
  • ctags: 1
  • sloc: sh: 13,935; perl: 157; makefile: 114
file content (258 lines) | stat: -rw-r--r-- 7,156 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
.\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
.\"     <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
.\"         all rights reserved.
.\" Translated 2008-08-17, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.07
.\" 
.\"WORD:	significand	
.\"WORD:	domain error	ΰ襨顼
.\"WORD:	pole error	˥顼
.\"WORD:	range error	ϰϥ顼
.\" 
.TH MATH_ERROR 7 2008-08-11 "Linux" "Linux Programmer's Manual"
.SH ̾
math_error \- شؿΥ顼θ
.SH 
.nf
.B #include <math.h>
.B #include <errno.h>
.B #include <fenv.h>
.fi
.SH 
顼ȯȡۤȤɤΥ饤֥ؿ (\-1  NULL ʤɤ)
̤֤ͤȤǥ顼Τ롣
.I <math.h>
Ƥشؿϡ̾ư֤ͤΤǡ
¾εȤäƥ顼Τ롣
顼ε 2 ढꡢ
ŤΤ
.I errno
ꤹǤꡢΤ
.BR fenv (3)
Ƥư㳰Ǥ롣
.RB ( feclearexcept (3)

.BR fetestexcept (3)
Ѥ롣ˤĤƤϰʲdzפƤ롣)

ܿɬפʥץǡشؿΥ顼ǧɬפˤϡ
شؿƤӽФ
.I errno
 0 ꤷʲƤӽФ٤Ǥ롣
.in +4n
.nf

feclearexcept(FE_ALL_EXCEPT);
.fi
.in

شؿ֤äƤݤˡ
.I errno
 0 ʳʲθƤӽФ 0 ʳ֤
.RB ( fenv (3)
)شؿǥ顼ȯƤ롣
.in +4n
.nf

fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW |
             FE_UNDERFLOW);
.fi
.in
.\" enum
.\" {
.\" FE_INVALID = 0x01,
.\" __FE_DENORM = 0x02,
.\" FE_DIVBYZERO = 0x04,
.\" FE_OVERFLOW = 0x08,
.\" FE_UNDERFLOW = 0x10,
.\" FE_INEXACT = 0x20
.\" };

شؿȯ륨顼ˤĤƤϰʲ롣
.SS ΰ襨顼 (domain error)
.I ΰ襨顼
ȯΤϡشؿϤ줿ͤδؿƤ
ΰäƤʤǤ (㤨
.BR log (3)
ΰϤ)
ΰ襨顼ȯȡ
شؿ̤ NaN ֤
(Ʊǰ㤦֤ͤؿ⤢)
.I errno

.B EDOM
ꤷ̵ (invalid)
ư㳰
.RB ( FE_INVALID )
夲롣
.SS ˥顼 (pole error)
.I ˥顼
ȯΤϡؿοŪʷ̵̤礽ΤΤȤʤǤ
(㤨
0 п̵Ǥ)
˥顼ȯȡδؿ֤ͤ (դ)
.BR HUGE_VAL ,
.BR HUGE_VALF ,
.B HUGE_VALL
Τ줫Ȥʤ (ͤΤɤ줬֤뤫ϴؿ֤ͤηˤޤꡢ
.IR double ,
.IR float ,
.I "long double"
б)
̤ϡδؿοŪꤵ롣
.I errno

.B ERANGE
ꤵ졢0 ˤ (divide-by-zero)
ư㳰
.RB ( FE_DIVBYZERO )
夬롣
.SS ϰϥ顼 (range 顼)
.I ϰϥ顼
ȯΤϡؿη̤ͤδؿ֤ͤηǤɽǤʤ
Ǥ롣ؿ֤ͤϡϰϥ顼СեǤäե
Ǥäˤäưۤʤ롣

ưΥСեϡ̤ͭ¤礭᤮
̤֤ǤɽǤʤȯ롣
Сեȯȡ
δؿ
.BR HUGE_VAL ,
.BR HUGE_VALF ,
.B HUGE_VALL
Τ줫֤ (ͤΤɤ줬֤뤫ϴؿ֤ͤηˤޤꡢ
.IR double ,
.IR float ,
.I "long double"
б)
.I errno

.B ERANGE
ꤵ졢֥Сե (overflow)
ư㳰
.RB ( FE_OVERFLOW )
夬롣

ưΥեϡ
̤᤮ơ̤֤ǤɽǤʤȯ롣
եȯȡشؿ̾ 0.0 ֤
(C99 Ǥϡꤵ줿ˤƺǾ줿ͤ礭ʤ
ͤļ (implementation-defined) ֤ͤȤʤäƤ)
.I errno

.B ERANGE
ꤵ졢֥եư㳰
.RB ( FE_UNDERFLOW )
夬롣

ĤδؿǤϡϤ줿ͤ䡢ؿη̤
.I subnormal ()
ˤʤϰϥ顼夲롣
subnormal ͤȤϡ0 ǤϤʤͤ
(κǾ̥ӥåȤ 1 Ȥʤ) ɸǤɽǤʤ褦ͤǤ롣
subnormal ͤɽǤϡξ¦ΥӥåȤ 1 İʾ 0 
ޤޤ뤳Ȥˤʤ롣
.SH 
C99  POSIX.1-2001 ǵꤵƤ
.I math_errhandling
̻Ҥ glibc ǤϥݡȤƤʤ
.\" See CONFORMANCE in the glibc 2.8 (and earlier) source.
μ̻Ҥϡ2 ĤΥ顼ε
.RI ( errno

.BR fetestexcept (3)
ͳǼǤ㳰) Τɤ餬ѤƤ뤫
뤳ȤˤʤäƤ롣
ɸǤϡʤȤĤϻѤ뤳Ȥ׵ᤵƤ뤬
ξȤѲǽǤäƤ褤ȤƤ롣
glibc Ǥθߤ (С 2.8 Ǥ) Ϥʤ꺮𤷤Ƥ롣
ۤȤɤδؿ (ǤϤʤ) ϥ顼㳰夲롣
Ĥδؿ
.I errno
ꤹ롣
.I errno
ꤹ뤬㳰夲ʤؿ⾯¸ߤ롣
ɤԤʤؿ⤴¸ߤ롣
ܺ٤ˤĤƤϸġΥޥ˥奢ڡ򻲾ȤΤȡ

.I errno

.BR fetestexcept (3)
ξȤäƥ顼åԤȤʣˤʤΤ򤱤뤿ᡢ
¿ξ硢ؿƤӽФԤʰΥåԤ
ˡ侩Ƥ롣
.\" http://www.securecoding.cert.org/confluence/display/seccode/FLP32-C.+Prevent+or+detect+domain+and+range+errors+in+math+functions
㤨СʲΥɤϡ
.BR log (3)
ΰ NaN Ǥ (˥顼Ȥʤ) 0 Ǥ (ΰ襨顼Ȥʤ) 0 ̤
ǤʤȤݾڤΤǤ롣
.in +4n
.nf

double x, r;

if (isnan(x) || islessequal(x, 0)) {
    /* Deal with NaN / pole error / domain error */
}

r = log(x);

.fi
.in
Υڡ˽񤫤Ƥ뤳Ȥϡ
.RI ( <complex.h>
Ƥ) ʣǿؿˤϤƤϤޤʤ
̤ˡC99  POSIX.1-2001 ǤϤδؿ顼֤Ȥ
׵ᤷƤʤ

.BR gcc (1)

.I "-fno-math-errno"
ץȤȡ¹ԥեǡɸμ®ʿشؿ
Ѥ褦ˤʤ뤬
.I errno
ꤵʤ
.RB ( gcc (1)

.I "-ffast-math"
ץꤷˤ
.I "-fno-math-errno"
ͭˤʤ)
ΥץꤷǤ⡢
.BR fetestexcept (3)
Ȥä顼θϲǽǤ롣
.SH Ϣ
.BR gcc (1),
.BR errno (3),
.BR fenv (3),
.BR fpclassify (3),
.BR INFINITY (3),
.BR isgreater (3),
.BR matherr (3),
.BR nan (3)
.br
.I "info libc"