Rev 4973 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4973 | Rev 5098 | ||
---|---|---|---|
1 | /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
1 | /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
2 | /* @(#)k_standard.c 5.1 93/09/24 */ |
2 | /* @(#)k_standard.c 5.1 93/09/24 */ |
3 | /* |
3 | /* |
4 | * ==================================================== |
4 | * ==================================================== |
5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
6 | * |
6 | * |
7 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
7 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
8 | * Permission to use, copy, modify, and distribute this |
8 | * Permission to use, copy, modify, and distribute this |
9 | * software is freely granted, provided that this notice |
9 | * software is freely granted, provided that this notice |
10 | * is preserved. |
10 | * is preserved. |
11 | * ==================================================== |
11 | * ==================================================== |
12 | */ |
12 | */ |
13 | 13 | ||
14 | #if defined(LIBM_SCCS) && !defined(lint) |
14 | #if defined(LIBM_SCCS) && !defined(lint) |
15 | static char rcsid[] = "$Id: k_standard.c,v 1.4 1994/08/10 20:31:44 jtc Exp $"; |
15 | static char rcsid[] = "$Id: k_standard.c,v 1.4 1994/08/10 20:31:44 jtc Exp $"; |
16 | #endif |
16 | #endif |
17 | 17 | ||
18 | #include "math.h" |
18 | #include "math.h" |
19 | #include "math_private.h" |
19 | #include "math_private.h" |
20 | #include |
20 | #include |
21 | 21 | ||
22 | #ifndef _USE_WRITE |
22 | #ifndef _USE_WRITE |
23 | #include |
23 | #include |
24 | #define WRITE2(u,v) fputs(u, stderr) |
24 | #define WRITE2(u,v) fputs(u, stderr) |
25 | #else /* !defined(_USE_WRITE) */ |
25 | #else /* !defined(_USE_WRITE) */ |
26 | #include |
26 | #include |
27 | #define WRITE2(u,v) write(2, u, v) |
27 | #define WRITE2(u,v) write(2, u, v) |
28 | #undef fflush |
28 | #undef fflush |
29 | #endif /* !defined(_USE_WRITE) */ |
29 | #endif /* !defined(_USE_WRITE) */ |
- | 30 | ||
- | 31 | inline int fputs(const char* str, FILE* f) { return -1; } |
|
30 | 32 | ||
31 | #ifdef __STDC__ |
33 | #ifdef __STDC__ |
32 | static const double zero = 0.0; /* used as const */ |
34 | static const double zero = 0.0; /* used as const */ |
33 | #else |
35 | #else |
34 | static double zero = 0.0; /* used as const */ |
36 | static double zero = 0.0; /* used as const */ |
35 | #endif |
37 | #endif |
36 | 38 | ||
37 | /* |
39 | /* |
38 | * Standard conformance (non-IEEE) on exception cases. |
40 | * Standard conformance (non-IEEE) on exception cases. |
39 | * Mapping: |
41 | * Mapping: |
40 | * 1 -- acos(|x|>1) |
42 | * 1 -- acos(|x|>1) |
41 | * 2 -- asin(|x|>1) |
43 | * 2 -- asin(|x|>1) |
42 | * 3 -- atan2(+-0,+-0) |
44 | * 3 -- atan2(+-0,+-0) |
43 | * 4 -- hypot overflow |
45 | * 4 -- hypot overflow |
44 | * 5 -- cosh overflow |
46 | * 5 -- cosh overflow |
45 | * 6 -- exp overflow |
47 | * 6 -- exp overflow |
46 | * 7 -- exp underflow |
48 | * 7 -- exp underflow |
47 | * 8 -- y0(0) |
49 | * 8 -- y0(0) |
48 | * 9 -- y0(-ve) |
50 | * 9 -- y0(-ve) |
49 | * 10-- y1(0) |
51 | * 10-- y1(0) |
50 | * 11-- y1(-ve) |
52 | * 11-- y1(-ve) |
51 | * 12-- yn(0) |
53 | * 12-- yn(0) |
52 | * 13-- yn(-ve) |
54 | * 13-- yn(-ve) |
53 | * 14-- lgamma(finite) overflow |
55 | * 14-- lgamma(finite) overflow |
54 | * 15-- lgamma(-integer) |
56 | * 15-- lgamma(-integer) |
55 | * 16-- log(0) |
57 | * 16-- log(0) |
56 | * 17-- log(x<0) |
58 | * 17-- log(x<0) |
57 | * 18-- log10(0) |
59 | * 18-- log10(0) |
58 | * 19-- log10(x<0) |
60 | * 19-- log10(x<0) |
59 | * 20-- pow(0.0,0.0) |
61 | * 20-- pow(0.0,0.0) |
60 | * 21-- pow(x,y) overflow |
62 | * 21-- pow(x,y) overflow |
61 | * 22-- pow(x,y) underflow |
63 | * 22-- pow(x,y) underflow |
62 | * 23-- pow(0,negative) |
64 | * 23-- pow(0,negative) |
63 | * 24-- pow(neg,non-integral) |
65 | * 24-- pow(neg,non-integral) |
64 | * 25-- sinh(finite) overflow |
66 | * 25-- sinh(finite) overflow |
65 | * 26-- sqrt(negative) |
67 | * 26-- sqrt(negative) |
66 | * 27-- fmod(x,0) |
68 | * 27-- fmod(x,0) |
67 | * 28-- remainder(x,0) |
69 | * 28-- remainder(x,0) |
68 | * 29-- acosh(x<1) |
70 | * 29-- acosh(x<1) |
69 | * 30-- atanh(|x|>1) |
71 | * 30-- atanh(|x|>1) |
70 | * 31-- atanh(|x|=1) |
72 | * 31-- atanh(|x|=1) |
71 | * 32-- scalb overflow |
73 | * 32-- scalb overflow |
72 | * 33-- scalb underflow |
74 | * 33-- scalb underflow |
73 | * 34-- j0(|x|>X_TLOSS) |
75 | * 34-- j0(|x|>X_TLOSS) |
74 | * 35-- y0(x>X_TLOSS) |
76 | * 35-- y0(x>X_TLOSS) |
75 | * 36-- j1(|x|>X_TLOSS) |
77 | * 36-- j1(|x|>X_TLOSS) |
76 | * 37-- y1(x>X_TLOSS) |
78 | * 37-- y1(x>X_TLOSS) |
77 | * 38-- jn(|x|>X_TLOSS, n) |
79 | * 38-- jn(|x|>X_TLOSS, n) |
78 | * 39-- yn(x>X_TLOSS, n) |
80 | * 39-- yn(x>X_TLOSS, n) |
79 | * 40-- gamma(finite) overflow |
81 | * 40-- gamma(finite) overflow |
80 | * 41-- gamma(-integer) |
82 | * 41-- gamma(-integer) |
81 | * 42-- pow(NaN,0.0) |
83 | * 42-- pow(NaN,0.0) |
82 | */ |
84 | */ |
83 | 85 | ||
84 | 86 | ||
85 | #ifdef __STDC__ |
87 | #ifdef __STDC__ |
86 | double __kernel_standard(double x, double y, int type) |
88 | double __kernel_standard(double x, double y, int type) |
87 | #else |
89 | #else |
88 | double __kernel_standard(x,y,type) |
90 | double __kernel_standard(x,y,type) |
89 | double x,y; int type; |
91 | double x,y; int type; |
90 | #endif |
92 | #endif |
91 | { |
93 | { |
92 | struct exception exc; |
94 | struct exception exc; |
93 | #ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ |
95 | #ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ |
94 | #define HUGE_VAL inf |
96 | #define HUGE_VAL inf |
95 | double inf = 0.0; |
97 | double inf = 0.0; |
96 | 98 | ||
97 | SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
99 | SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
98 | #endif |
100 | #endif |
99 | 101 | ||
100 | #ifdef _USE_WRITE |
102 | #ifdef _USE_WRITE |
101 | (void) fflush(stdout); |
103 | (void) fflush(stdout); |
102 | #endif |
104 | #endif |
103 | exc.arg1 = x; |
105 | exc.arg1 = x; |
104 | exc.arg2 = y; |
106 | exc.arg2 = y; |
105 | switch(type) { |
107 | switch(type) { |
106 | case 1: |
108 | case 1: |
107 | case 101: |
109 | case 101: |
108 | /* acos(|x|>1) */ |
110 | /* acos(|x|>1) */ |
109 | exc.type = DOMAIN; |
111 | exc.type = DOMAIN; |
110 | exc.name = type < 100 ? "acos" : "acosf"; |
112 | exc.name = type < 100 ? "acos" : "acosf"; |
111 | exc.retval = zero; |
113 | exc.retval = zero; |
112 | if (_LIB_VERSION == _POSIX_) |
114 | if (_LIB_VERSION == _POSIX_) |
113 | errno = EDOM; |
115 | errno = EDOM; |
114 | else if (!matherr(&exc)) { |
116 | else if (!matherr(&exc)) { |
115 | if(_LIB_VERSION == _SVID_) { |
117 | if(_LIB_VERSION == _SVID_) { |
116 | (void) WRITE2("acos: DOMAIN error\n", 19); |
118 | (void) WRITE2("acos: DOMAIN error\n", 19); |
117 | } |
119 | } |
118 | errno = EDOM; |
120 | errno = EDOM; |
119 | } |
121 | } |
120 | break; |
122 | break; |
121 | case 2: |
123 | case 2: |
122 | case 102: |
124 | case 102: |
123 | /* asin(|x|>1) */ |
125 | /* asin(|x|>1) */ |
124 | exc.type = DOMAIN; |
126 | exc.type = DOMAIN; |
125 | exc.name = type < 100 ? "asin" : "asinf"; |
127 | exc.name = type < 100 ? "asin" : "asinf"; |
126 | exc.retval = zero; |
128 | exc.retval = zero; |
127 | if(_LIB_VERSION == _POSIX_) |
129 | if(_LIB_VERSION == _POSIX_) |
128 | errno = EDOM; |
130 | errno = EDOM; |
129 | else if (!matherr(&exc)) { |
131 | else if (!matherr(&exc)) { |
130 | if(_LIB_VERSION == _SVID_) { |
132 | if(_LIB_VERSION == _SVID_) { |
131 | (void) WRITE2("asin: DOMAIN error\n", 19); |
133 | (void) WRITE2("asin: DOMAIN error\n", 19); |
132 | } |
134 | } |
133 | errno = EDOM; |
135 | errno = EDOM; |
134 | } |
136 | } |
135 | break; |
137 | break; |
136 | case 3: |
138 | case 3: |
137 | case 103: |
139 | case 103: |
138 | /* atan2(+-0,+-0) */ |
140 | /* atan2(+-0,+-0) */ |
139 | exc.arg1 = y; |
141 | exc.arg1 = y; |
140 | exc.arg2 = x; |
142 | exc.arg2 = x; |
141 | exc.type = DOMAIN; |
143 | exc.type = DOMAIN; |
142 | exc.name = type < 100 ? "atan2" : "atan2f"; |
144 | exc.name = type < 100 ? "atan2" : "atan2f"; |
143 | exc.retval = zero; |
145 | exc.retval = zero; |
144 | if(_LIB_VERSION == _POSIX_) |
146 | if(_LIB_VERSION == _POSIX_) |
145 | errno = EDOM; |
147 | errno = EDOM; |
146 | else if (!matherr(&exc)) { |
148 | else if (!matherr(&exc)) { |
147 | if(_LIB_VERSION == _SVID_) { |
149 | if(_LIB_VERSION == _SVID_) { |
148 | (void) WRITE2("atan2: DOMAIN error\n", 20); |
150 | (void) WRITE2("atan2: DOMAIN error\n", 20); |
149 | } |
151 | } |
150 | errno = EDOM; |
152 | errno = EDOM; |
151 | } |
153 | } |
152 | break; |
154 | break; |
153 | case 4: |
155 | case 4: |
154 | case 104: |
156 | case 104: |
155 | /* hypot(finite,finite) overflow */ |
157 | /* hypot(finite,finite) overflow */ |
156 | exc.type = OVERFLOW; |
158 | exc.type = OVERFLOW; |
157 | exc.name = type < 100 ? "hypot" : "hypotf"; |
159 | exc.name = type < 100 ? "hypot" : "hypotf"; |
158 | if (_LIB_VERSION == _SVID_) |
160 | if (_LIB_VERSION == _SVID_) |
159 | exc.retval = HUGE_VAL; |
161 | exc.retval = HUGE_VAL; |
160 | else |
162 | else |
161 | exc.retval = HUGE_VAL; |
163 | exc.retval = HUGE_VAL; |
162 | if (_LIB_VERSION == _POSIX_) |
164 | if (_LIB_VERSION == _POSIX_) |
163 | errno = ERANGE; |
165 | errno = ERANGE; |
164 | else if (!matherr(&exc)) { |
166 | else if (!matherr(&exc)) { |
165 | errno = ERANGE; |
167 | errno = ERANGE; |
166 | } |
168 | } |
167 | break; |
169 | break; |
168 | case 5: |
170 | case 5: |
169 | case 105: |
171 | case 105: |
170 | /* cosh(finite) overflow */ |
172 | /* cosh(finite) overflow */ |
171 | exc.type = OVERFLOW; |
173 | exc.type = OVERFLOW; |
172 | exc.name = type < 100 ? "cosh" : "coshf"; |
174 | exc.name = type < 100 ? "cosh" : "coshf"; |
173 | if (_LIB_VERSION == _SVID_) |
175 | if (_LIB_VERSION == _SVID_) |
174 | exc.retval = HUGE_VAL; |
176 | exc.retval = HUGE_VAL; |
175 | else |
177 | else |
176 | exc.retval = HUGE_VAL; |
178 | exc.retval = HUGE_VAL; |
177 | if (_LIB_VERSION == _POSIX_) |
179 | if (_LIB_VERSION == _POSIX_) |
178 | errno = ERANGE; |
180 | errno = ERANGE; |
179 | else if (!matherr(&exc)) { |
181 | else if (!matherr(&exc)) { |
180 | errno = ERANGE; |
182 | errno = ERANGE; |
181 | } |
183 | } |
182 | break; |
184 | break; |
183 | case 6: |
185 | case 6: |
184 | case 106: |
186 | case 106: |
185 | /* exp(finite) overflow */ |
187 | /* exp(finite) overflow */ |
186 | exc.type = OVERFLOW; |
188 | exc.type = OVERFLOW; |
187 | exc.name = type < 100 ? "exp" : "expf"; |
189 | exc.name = type < 100 ? "exp" : "expf"; |
188 | if (_LIB_VERSION == _SVID_) |
190 | if (_LIB_VERSION == _SVID_) |
189 | exc.retval = HUGE_VAL; |
191 | exc.retval = HUGE_VAL; |
190 | else |
192 | else |
191 | exc.retval = HUGE_VAL; |
193 | exc.retval = HUGE_VAL; |
192 | if (_LIB_VERSION == _POSIX_) |
194 | if (_LIB_VERSION == _POSIX_) |
193 | errno = ERANGE; |
195 | errno = ERANGE; |
194 | else if (!matherr(&exc)) { |
196 | else if (!matherr(&exc)) { |
195 | errno = ERANGE; |
197 | errno = ERANGE; |
196 | } |
198 | } |
197 | break; |
199 | break; |
198 | case 7: |
200 | case 7: |
199 | case 107: |
201 | case 107: |
200 | /* exp(finite) underflow */ |
202 | /* exp(finite) underflow */ |
201 | exc.type = UNDERFLOW; |
203 | exc.type = UNDERFLOW; |
202 | exc.name = type < 100 ? "exp" : "expf"; |
204 | exc.name = type < 100 ? "exp" : "expf"; |
203 | exc.retval = zero; |
205 | exc.retval = zero; |
204 | if (_LIB_VERSION == _POSIX_) |
206 | if (_LIB_VERSION == _POSIX_) |
205 | errno = ERANGE; |
207 | errno = ERANGE; |
206 | else if (!matherr(&exc)) { |
208 | else if (!matherr(&exc)) { |
207 | errno = ERANGE; |
209 | errno = ERANGE; |
208 | } |
210 | } |
209 | break; |
211 | break; |
210 | case 8: |
212 | case 8: |
211 | case 108: |
213 | case 108: |
212 | /* y0(0) = -inf */ |
214 | /* y0(0) = -inf */ |
213 | exc.type = DOMAIN; /* should be SING for IEEE */ |
215 | exc.type = DOMAIN; /* should be SING for IEEE */ |
214 | exc.name = type < 100 ? "y0" : "y0f"; |
216 | exc.name = type < 100 ? "y0" : "y0f"; |
215 | if (_LIB_VERSION == _SVID_) |
217 | if (_LIB_VERSION == _SVID_) |
216 | exc.retval = -HUGE_VAL; |
218 | exc.retval = -HUGE_VAL; |
217 | else |
219 | else |
218 | exc.retval = -HUGE_VAL; |
220 | exc.retval = -HUGE_VAL; |
219 | if (_LIB_VERSION == _POSIX_) |
221 | if (_LIB_VERSION == _POSIX_) |
220 | errno = EDOM; |
222 | errno = EDOM; |
221 | else if (!matherr(&exc)) { |
223 | else if (!matherr(&exc)) { |
222 | if (_LIB_VERSION == _SVID_) { |
224 | if (_LIB_VERSION == _SVID_) { |
223 | (void) WRITE2("y0: DOMAIN error\n", 17); |
225 | (void) WRITE2("y0: DOMAIN error\n", 17); |
224 | } |
226 | } |
225 | errno = EDOM; |
227 | errno = EDOM; |
226 | } |
228 | } |
227 | break; |
229 | break; |
228 | case 9: |
230 | case 9: |
229 | case 109: |
231 | case 109: |
230 | /* y0(x<0) = NaN */ |
232 | /* y0(x<0) = NaN */ |
231 | exc.type = DOMAIN; |
233 | exc.type = DOMAIN; |
232 | exc.name = type < 100 ? "y0" : "y0f"; |
234 | exc.name = type < 100 ? "y0" : "y0f"; |
233 | if (_LIB_VERSION == _SVID_) |
235 | if (_LIB_VERSION == _SVID_) |
234 | exc.retval = -HUGE_VAL; |
236 | exc.retval = -HUGE_VAL; |
235 | else |
237 | else |
236 | exc.retval = -HUGE_VAL; |
238 | exc.retval = -HUGE_VAL; |
237 | if (_LIB_VERSION == _POSIX_) |
239 | if (_LIB_VERSION == _POSIX_) |
238 | errno = EDOM; |
240 | errno = EDOM; |
239 | else if (!matherr(&exc)) { |
241 | else if (!matherr(&exc)) { |
240 | if (_LIB_VERSION == _SVID_) { |
242 | if (_LIB_VERSION == _SVID_) { |
241 | (void) WRITE2("y0: DOMAIN error\n", 17); |
243 | (void) WRITE2("y0: DOMAIN error\n", 17); |
242 | } |
244 | } |
243 | errno = EDOM; |
245 | errno = EDOM; |
244 | } |
246 | } |
245 | break; |
247 | break; |
246 | case 10: |
248 | case 10: |
247 | case 110: |
249 | case 110: |
248 | /* y1(0) = -inf */ |
250 | /* y1(0) = -inf */ |
249 | exc.type = DOMAIN; /* should be SING for IEEE */ |
251 | exc.type = DOMAIN; /* should be SING for IEEE */ |
250 | exc.name = type < 100 ? "y1" : "y1f"; |
252 | exc.name = type < 100 ? "y1" : "y1f"; |
251 | if (_LIB_VERSION == _SVID_) |
253 | if (_LIB_VERSION == _SVID_) |
252 | exc.retval = -HUGE_VAL; |
254 | exc.retval = -HUGE_VAL; |
253 | else |
255 | else |
254 | exc.retval = -HUGE_VAL; |
256 | exc.retval = -HUGE_VAL; |
255 | if (_LIB_VERSION == _POSIX_) |
257 | if (_LIB_VERSION == _POSIX_) |
256 | errno = EDOM; |
258 | errno = EDOM; |
257 | else if (!matherr(&exc)) { |
259 | else if (!matherr(&exc)) { |
258 | if (_LIB_VERSION == _SVID_) { |
260 | if (_LIB_VERSION == _SVID_) { |
259 | (void) WRITE2("y1: DOMAIN error\n", 17); |
261 | (void) WRITE2("y1: DOMAIN error\n", 17); |
260 | } |
262 | } |
261 | errno = EDOM; |
263 | errno = EDOM; |
262 | } |
264 | } |
263 | break; |
265 | break; |
264 | case 11: |
266 | case 11: |
265 | case 111: |
267 | case 111: |
266 | /* y1(x<0) = NaN */ |
268 | /* y1(x<0) = NaN */ |
267 | exc.type = DOMAIN; |
269 | exc.type = DOMAIN; |
268 | exc.name = type < 100 ? "y1" : "y1f"; |
270 | exc.name = type < 100 ? "y1" : "y1f"; |
269 | if (_LIB_VERSION == _SVID_) |
271 | if (_LIB_VERSION == _SVID_) |
270 | exc.retval = -HUGE_VAL; |
272 | exc.retval = -HUGE_VAL; |
271 | else |
273 | else |
272 | exc.retval = -HUGE_VAL; |
274 | exc.retval = -HUGE_VAL; |
273 | if (_LIB_VERSION == _POSIX_) |
275 | if (_LIB_VERSION == _POSIX_) |
274 | errno = EDOM; |
276 | errno = EDOM; |
275 | else if (!matherr(&exc)) { |
277 | else if (!matherr(&exc)) { |
276 | if (_LIB_VERSION == _SVID_) { |
278 | if (_LIB_VERSION == _SVID_) { |
277 | (void) WRITE2("y1: DOMAIN error\n", 17); |
279 | (void) WRITE2("y1: DOMAIN error\n", 17); |
278 | } |
280 | } |
279 | errno = EDOM; |
281 | errno = EDOM; |
280 | } |
282 | } |
281 | break; |
283 | break; |
282 | case 12: |
284 | case 12: |
283 | case 112: |
285 | case 112: |
284 | /* yn(n,0) = -inf */ |
286 | /* yn(n,0) = -inf */ |
285 | exc.type = DOMAIN; /* should be SING for IEEE */ |
287 | exc.type = DOMAIN; /* should be SING for IEEE */ |
286 | exc.name = type < 100 ? "yn" : "ynf"; |
288 | exc.name = type < 100 ? "yn" : "ynf"; |
287 | if (_LIB_VERSION == _SVID_) |
289 | if (_LIB_VERSION == _SVID_) |
288 | exc.retval = -HUGE_VAL; |
290 | exc.retval = -HUGE_VAL; |
289 | else |
291 | else |
290 | exc.retval = -HUGE_VAL; |
292 | exc.retval = -HUGE_VAL; |
291 | if (_LIB_VERSION == _POSIX_) |
293 | if (_LIB_VERSION == _POSIX_) |
292 | errno = EDOM; |
294 | errno = EDOM; |
293 | else if (!matherr(&exc)) { |
295 | else if (!matherr(&exc)) { |
294 | if (_LIB_VERSION == _SVID_) { |
296 | if (_LIB_VERSION == _SVID_) { |
295 | (void) WRITE2("yn: DOMAIN error\n", 17); |
297 | (void) WRITE2("yn: DOMAIN error\n", 17); |
296 | } |
298 | } |
297 | errno = EDOM; |
299 | errno = EDOM; |
298 | } |
300 | } |
299 | break; |
301 | break; |
300 | case 13: |
302 | case 13: |
301 | case 113: |
303 | case 113: |
302 | /* yn(x<0) = NaN */ |
304 | /* yn(x<0) = NaN */ |
303 | exc.type = DOMAIN; |
305 | exc.type = DOMAIN; |
304 | exc.name = type < 100 ? "yn" : "ynf"; |
306 | exc.name = type < 100 ? "yn" : "ynf"; |
305 | if (_LIB_VERSION == _SVID_) |
307 | if (_LIB_VERSION == _SVID_) |
306 | exc.retval = -HUGE_VAL; |
308 | exc.retval = -HUGE_VAL; |
307 | else |
309 | else |
308 | exc.retval = -HUGE_VAL; |
310 | exc.retval = -HUGE_VAL; |
309 | if (_LIB_VERSION == _POSIX_) |
311 | if (_LIB_VERSION == _POSIX_) |
310 | errno = EDOM; |
312 | errno = EDOM; |
311 | else if (!matherr(&exc)) { |
313 | else if (!matherr(&exc)) { |
312 | if (_LIB_VERSION == _SVID_) { |
314 | if (_LIB_VERSION == _SVID_) { |
313 | (void) WRITE2("yn: DOMAIN error\n", 17); |
315 | (void) WRITE2("yn: DOMAIN error\n", 17); |
314 | } |
316 | } |
315 | errno = EDOM; |
317 | errno = EDOM; |
316 | } |
318 | } |
317 | break; |
319 | break; |
318 | case 14: |
320 | case 14: |
319 | case 114: |
321 | case 114: |
320 | /* lgamma(finite) overflow */ |
322 | /* lgamma(finite) overflow */ |
321 | exc.type = OVERFLOW; |
323 | exc.type = OVERFLOW; |
322 | exc.name = type < 100 ? "lgamma" : "lgammaf"; |
324 | exc.name = type < 100 ? "lgamma" : "lgammaf"; |
323 | if (_LIB_VERSION == _SVID_) |
325 | if (_LIB_VERSION == _SVID_) |
324 | exc.retval = HUGE_VAL; |
326 | exc.retval = HUGE_VAL; |
325 | else |
327 | else |
326 | exc.retval = HUGE_VAL; |
328 | exc.retval = HUGE_VAL; |
327 | if (_LIB_VERSION == _POSIX_) |
329 | if (_LIB_VERSION == _POSIX_) |
328 | errno = ERANGE; |
330 | errno = ERANGE; |
329 | else if (!matherr(&exc)) { |
331 | else if (!matherr(&exc)) { |
330 | errno = ERANGE; |
332 | errno = ERANGE; |
331 | } |
333 | } |
332 | break; |
334 | break; |
333 | case 15: |
335 | case 15: |
334 | case 115: |
336 | case 115: |
335 | /* lgamma(-integer) or lgamma(0) */ |
337 | /* lgamma(-integer) or lgamma(0) */ |
336 | exc.type = SING; |
338 | exc.type = SING; |
337 | exc.name = type < 100 ? "lgamma" : "lgammaf"; |
339 | exc.name = type < 100 ? "lgamma" : "lgammaf"; |
338 | if (_LIB_VERSION == _SVID_) |
340 | if (_LIB_VERSION == _SVID_) |
339 | exc.retval = HUGE_VAL; |
341 | exc.retval = HUGE_VAL; |
340 | else |
342 | else |
341 | exc.retval = HUGE_VAL; |
343 | exc.retval = HUGE_VAL; |
342 | if (_LIB_VERSION == _POSIX_) |
344 | if (_LIB_VERSION == _POSIX_) |
343 | errno = EDOM; |
345 | errno = EDOM; |
344 | else if (!matherr(&exc)) { |
346 | else if (!matherr(&exc)) { |
345 | if (_LIB_VERSION == _SVID_) { |
347 | if (_LIB_VERSION == _SVID_) { |
346 | (void) WRITE2("lgamma: SING error\n", 19); |
348 | (void) WRITE2("lgamma: SING error\n", 19); |
347 | } |
349 | } |
348 | errno = EDOM; |
350 | errno = EDOM; |
349 | } |
351 | } |
350 | break; |
352 | break; |
351 | case 16: |
353 | case 16: |
352 | case 116: |
354 | case 116: |
353 | /* log(0) */ |
355 | /* log(0) */ |
354 | exc.type = SING; |
356 | exc.type = SING; |
355 | exc.name = type < 100 ? "log" : "logf"; |
357 | exc.name = type < 100 ? "log" : "logf"; |
356 | if (_LIB_VERSION == _SVID_) |
358 | if (_LIB_VERSION == _SVID_) |
357 | exc.retval = -HUGE_VAL; |
359 | exc.retval = -HUGE_VAL; |
358 | else |
360 | else |
359 | exc.retval = -HUGE_VAL; |
361 | exc.retval = -HUGE_VAL; |
360 | if (_LIB_VERSION == _POSIX_) |
362 | if (_LIB_VERSION == _POSIX_) |
361 | errno = ERANGE; |
363 | errno = ERANGE; |
362 | else if (!matherr(&exc)) { |
364 | else if (!matherr(&exc)) { |
363 | if (_LIB_VERSION == _SVID_) { |
365 | if (_LIB_VERSION == _SVID_) { |
364 | (void) WRITE2("log: SING error\n", 16); |
366 | (void) WRITE2("log: SING error\n", 16); |
365 | } |
367 | } |
366 | errno = EDOM; |
368 | errno = EDOM; |
367 | } |
369 | } |
368 | break; |
370 | break; |
369 | case 17: |
371 | case 17: |
370 | case 117: |
372 | case 117: |
371 | /* log(x<0) */ |
373 | /* log(x<0) */ |
372 | exc.type = DOMAIN; |
374 | exc.type = DOMAIN; |
373 | exc.name = type < 100 ? "log" : "logf"; |
375 | exc.name = type < 100 ? "log" : "logf"; |
374 | if (_LIB_VERSION == _SVID_) |
376 | if (_LIB_VERSION == _SVID_) |
375 | exc.retval = -HUGE_VAL; |
377 | exc.retval = -HUGE_VAL; |
376 | else |
378 | else |
377 | exc.retval = -HUGE_VAL; |
379 | exc.retval = -HUGE_VAL; |
378 | if (_LIB_VERSION == _POSIX_) |
380 | if (_LIB_VERSION == _POSIX_) |
379 | errno = EDOM; |
381 | errno = EDOM; |
380 | else if (!matherr(&exc)) { |
382 | else if (!matherr(&exc)) { |
381 | if (_LIB_VERSION == _SVID_) { |
383 | if (_LIB_VERSION == _SVID_) { |
382 | (void) WRITE2("log: DOMAIN error\n", 18); |
384 | (void) WRITE2("log: DOMAIN error\n", 18); |
383 | } |
385 | } |
384 | errno = EDOM; |
386 | errno = EDOM; |
385 | } |
387 | } |
386 | break; |
388 | break; |
387 | case 18: |
389 | case 18: |
388 | case 118: |
390 | case 118: |
389 | /* log10(0) */ |
391 | /* log10(0) */ |
390 | exc.type = SING; |
392 | exc.type = SING; |
391 | exc.name = type < 100 ? "log10" : "log10f"; |
393 | exc.name = type < 100 ? "log10" : "log10f"; |
392 | if (_LIB_VERSION == _SVID_) |
394 | if (_LIB_VERSION == _SVID_) |
393 | exc.retval = -HUGE_VAL; |
395 | exc.retval = -HUGE_VAL; |
394 | else |
396 | else |
395 | exc.retval = -HUGE_VAL; |
397 | exc.retval = -HUGE_VAL; |
396 | if (_LIB_VERSION == _POSIX_) |
398 | if (_LIB_VERSION == _POSIX_) |
397 | errno = ERANGE; |
399 | errno = ERANGE; |
398 | else if (!matherr(&exc)) { |
400 | else if (!matherr(&exc)) { |
399 | if (_LIB_VERSION == _SVID_) { |
401 | if (_LIB_VERSION == _SVID_) { |
400 | (void) WRITE2("log10: SING error\n", 18); |
402 | (void) WRITE2("log10: SING error\n", 18); |
401 | } |
403 | } |
402 | errno = EDOM; |
404 | errno = EDOM; |
403 | } |
405 | } |
404 | break; |
406 | break; |
405 | case 19: |
407 | case 19: |
406 | case 119: |
408 | case 119: |
407 | /* log10(x<0) */ |
409 | /* log10(x<0) */ |
408 | exc.type = DOMAIN; |
410 | exc.type = DOMAIN; |
409 | exc.name = type < 100 ? "log10" : "log10f"; |
411 | exc.name = type < 100 ? "log10" : "log10f"; |
410 | if (_LIB_VERSION == _SVID_) |
412 | if (_LIB_VERSION == _SVID_) |
411 | exc.retval = -HUGE_VAL; |
413 | exc.retval = -HUGE_VAL; |
412 | else |
414 | else |
413 | exc.retval = -HUGE_VAL; |
415 | exc.retval = -HUGE_VAL; |
414 | if (_LIB_VERSION == _POSIX_) |
416 | if (_LIB_VERSION == _POSIX_) |
415 | errno = EDOM; |
417 | errno = EDOM; |
416 | else if (!matherr(&exc)) { |
418 | else if (!matherr(&exc)) { |
417 | if (_LIB_VERSION == _SVID_) { |
419 | if (_LIB_VERSION == _SVID_) { |
418 | (void) WRITE2("log10: DOMAIN error\n", 20); |
420 | (void) WRITE2("log10: DOMAIN error\n", 20); |
419 | } |
421 | } |
420 | errno = EDOM; |
422 | errno = EDOM; |
421 | } |
423 | } |
422 | break; |
424 | break; |
423 | case 20: |
425 | case 20: |
424 | case 120: |
426 | case 120: |
425 | /* pow(0.0,0.0) */ |
427 | /* pow(0.0,0.0) */ |
426 | /* error only if _LIB_VERSION == _SVID_ */ |
428 | /* error only if _LIB_VERSION == _SVID_ */ |
427 | exc.type = DOMAIN; |
429 | exc.type = DOMAIN; |
428 | exc.name = type < 100 ? "pow" : "powf"; |
430 | exc.name = type < 100 ? "pow" : "powf"; |
429 | exc.retval = zero; |
431 | exc.retval = zero; |
430 | if (_LIB_VERSION != _SVID_) exc.retval = 1.0; |
432 | if (_LIB_VERSION != _SVID_) exc.retval = 1.0; |
431 | else if (!matherr(&exc)) { |
433 | else if (!matherr(&exc)) { |
432 | (void) WRITE2("pow(0,0): DOMAIN error\n", 23); |
434 | (void) WRITE2("pow(0,0): DOMAIN error\n", 23); |
433 | errno = EDOM; |
435 | errno = EDOM; |
434 | } |
436 | } |
435 | break; |
437 | break; |
436 | case 21: |
438 | case 21: |
437 | case 121: |
439 | case 121: |
438 | /* pow(x,y) overflow */ |
440 | /* pow(x,y) overflow */ |
439 | exc.type = OVERFLOW; |
441 | exc.type = OVERFLOW; |
440 | exc.name = type < 100 ? "pow" : "powf"; |
442 | exc.name = type < 100 ? "pow" : "powf"; |
441 | if (_LIB_VERSION == _SVID_) { |
443 | if (_LIB_VERSION == _SVID_) { |
442 | exc.retval = HUGE_VAL; |
444 | exc.retval = HUGE_VAL; |
443 | y *= 0.5; |
445 | y *= 0.5; |
444 | if(x |
446 | if(x |
445 | } else { |
447 | } else { |
446 | exc.retval = HUGE_VAL; |
448 | exc.retval = HUGE_VAL; |
447 | y *= 0.5; |
449 | y *= 0.5; |
448 | if(x |
450 | if(x |
449 | } |
451 | } |
450 | if (_LIB_VERSION == _POSIX_) |
452 | if (_LIB_VERSION == _POSIX_) |
451 | errno = ERANGE; |
453 | errno = ERANGE; |
452 | else if (!matherr(&exc)) { |
454 | else if (!matherr(&exc)) { |
453 | errno = ERANGE; |
455 | errno = ERANGE; |
454 | } |
456 | } |
455 | break; |
457 | break; |
456 | case 22: |
458 | case 22: |
457 | case 122: |
459 | case 122: |
458 | /* pow(x,y) underflow */ |
460 | /* pow(x,y) underflow */ |
459 | exc.type = UNDERFLOW; |
461 | exc.type = UNDERFLOW; |
460 | exc.name = type < 100 ? "pow" : "powf"; |
462 | exc.name = type < 100 ? "pow" : "powf"; |
461 | exc.retval = zero; |
463 | exc.retval = zero; |
462 | if (_LIB_VERSION == _POSIX_) |
464 | if (_LIB_VERSION == _POSIX_) |
463 | errno = ERANGE; |
465 | errno = ERANGE; |
464 | else if (!matherr(&exc)) { |
466 | else if (!matherr(&exc)) { |
465 | errno = ERANGE; |
467 | errno = ERANGE; |
466 | } |
468 | } |
467 | break; |
469 | break; |
468 | case 23: |
470 | case 23: |
469 | case 123: |
471 | case 123: |
470 | /* 0**neg */ |
472 | /* 0**neg */ |
471 | exc.type = DOMAIN; |
473 | exc.type = DOMAIN; |
472 | exc.name = type < 100 ? "pow" : "powf"; |
474 | exc.name = type < 100 ? "pow" : "powf"; |
473 | if (_LIB_VERSION == _SVID_) |
475 | if (_LIB_VERSION == _SVID_) |
474 | exc.retval = zero; |
476 | exc.retval = zero; |
475 | else |
477 | else |
476 | exc.retval = -HUGE_VAL; |
478 | exc.retval = -HUGE_VAL; |
477 | if (_LIB_VERSION == _POSIX_) |
479 | if (_LIB_VERSION == _POSIX_) |
478 | errno = EDOM; |
480 | errno = EDOM; |
479 | else if (!matherr(&exc)) { |
481 | else if (!matherr(&exc)) { |
480 | if (_LIB_VERSION == _SVID_) { |
482 | if (_LIB_VERSION == _SVID_) { |
481 | (void) WRITE2("pow(0,neg): DOMAIN error\n", 25); |
483 | (void) WRITE2("pow(0,neg): DOMAIN error\n", 25); |
482 | } |
484 | } |
483 | errno = EDOM; |
485 | errno = EDOM; |
484 | } |
486 | } |
485 | break; |
487 | break; |
486 | case 24: |
488 | case 24: |
487 | case 124: |
489 | case 124: |
488 | /* neg**non-integral */ |
490 | /* neg**non-integral */ |
489 | exc.type = DOMAIN; |
491 | exc.type = DOMAIN; |
490 | exc.name = type < 100 ? "pow" : "powf"; |
492 | exc.name = type < 100 ? "pow" : "powf"; |
491 | if (_LIB_VERSION == _SVID_) |
493 | if (_LIB_VERSION == _SVID_) |
492 | exc.retval = zero; |
494 | exc.retval = zero; |
493 | else |
495 | else |
494 | exc.retval = zero/zero; /* X/Open allow NaN */ |
496 | exc.retval = zero/zero; /* X/Open allow NaN */ |
495 | if (_LIB_VERSION == _POSIX_) |
497 | if (_LIB_VERSION == _POSIX_) |
496 | errno = EDOM; |
498 | errno = EDOM; |
497 | else if (!matherr(&exc)) { |
499 | else if (!matherr(&exc)) { |
498 | if (_LIB_VERSION == _SVID_) { |
500 | if (_LIB_VERSION == _SVID_) { |
499 | (void) WRITE2("neg**non-integral: DOMAIN error\n", 32); |
501 | (void) WRITE2("neg**non-integral: DOMAIN error\n", 32); |
500 | } |
502 | } |
501 | errno = EDOM; |
503 | errno = EDOM; |
502 | } |
504 | } |
503 | break; |
505 | break; |
504 | case 25: |
506 | case 25: |
505 | case 125: |
507 | case 125: |
506 | /* sinh(finite) overflow */ |
508 | /* sinh(finite) overflow */ |
507 | exc.type = OVERFLOW; |
509 | exc.type = OVERFLOW; |
508 | exc.name = type < 100 ? "sinh" : "sinhf"; |
510 | exc.name = type < 100 ? "sinh" : "sinhf"; |
509 | if (_LIB_VERSION == _SVID_) |
511 | if (_LIB_VERSION == _SVID_) |
510 | exc.retval = ( (x>zero) ? HUGE_VAL: -HUGE_VAL); |
512 | exc.retval = ( (x>zero) ? HUGE_VAL: -HUGE_VAL); |
511 | else |
513 | else |
512 | exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); |
514 | exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); |
513 | if (_LIB_VERSION == _POSIX_) |
515 | if (_LIB_VERSION == _POSIX_) |
514 | errno = ERANGE; |
516 | errno = ERANGE; |
515 | else if (!matherr(&exc)) { |
517 | else if (!matherr(&exc)) { |
516 | errno = ERANGE; |
518 | errno = ERANGE; |
517 | } |
519 | } |
518 | break; |
520 | break; |
519 | case 26: |
521 | case 26: |
520 | case 126: |
522 | case 126: |
521 | /* sqrt(x<0) */ |
523 | /* sqrt(x<0) */ |
522 | exc.type = DOMAIN; |
524 | exc.type = DOMAIN; |
523 | exc.name = type < 100 ? "sqrt" : "sqrtf"; |
525 | exc.name = type < 100 ? "sqrt" : "sqrtf"; |
524 | if (_LIB_VERSION == _SVID_) |
526 | if (_LIB_VERSION == _SVID_) |
525 | exc.retval = zero; |
527 | exc.retval = zero; |
526 | else |
528 | else |
527 | exc.retval = zero/zero; |
529 | exc.retval = zero/zero; |
528 | if (_LIB_VERSION == _POSIX_) |
530 | if (_LIB_VERSION == _POSIX_) |
529 | errno = EDOM; |
531 | errno = EDOM; |
530 | else if (!matherr(&exc)) { |
532 | else if (!matherr(&exc)) { |
531 | if (_LIB_VERSION == _SVID_) { |
533 | if (_LIB_VERSION == _SVID_) { |
532 | (void) WRITE2("sqrt: DOMAIN error\n", 19); |
534 | (void) WRITE2("sqrt: DOMAIN error\n", 19); |
533 | } |
535 | } |
534 | errno = EDOM; |
536 | errno = EDOM; |
535 | } |
537 | } |
536 | break; |
538 | break; |
537 | case 27: |
539 | case 27: |
538 | case 127: |
540 | case 127: |
539 | /* fmod(x,0) */ |
541 | /* fmod(x,0) */ |
540 | exc.type = DOMAIN; |
542 | exc.type = DOMAIN; |
541 | exc.name = type < 100 ? "fmod" : "fmodf"; |
543 | exc.name = type < 100 ? "fmod" : "fmodf"; |
542 | if (_LIB_VERSION == _SVID_) |
544 | if (_LIB_VERSION == _SVID_) |
543 | exc.retval = x; |
545 | exc.retval = x; |
544 | else |
546 | else |
545 | exc.retval = zero/zero; |
547 | exc.retval = zero/zero; |
546 | if (_LIB_VERSION == _POSIX_) |
548 | if (_LIB_VERSION == _POSIX_) |
547 | errno = EDOM; |
549 | errno = EDOM; |
548 | else if (!matherr(&exc)) { |
550 | else if (!matherr(&exc)) { |
549 | if (_LIB_VERSION == _SVID_) { |
551 | if (_LIB_VERSION == _SVID_) { |
550 | (void) WRITE2("fmod: DOMAIN error\n", 20); |
552 | (void) WRITE2("fmod: DOMAIN error\n", 20); |
551 | } |
553 | } |
552 | errno = EDOM; |
554 | errno = EDOM; |
553 | } |
555 | } |
554 | break; |
556 | break; |
555 | case 28: |
557 | case 28: |
556 | case 128: |
558 | case 128: |
557 | /* remainder(x,0) */ |
559 | /* remainder(x,0) */ |
558 | exc.type = DOMAIN; |
560 | exc.type = DOMAIN; |
559 | exc.name = type < 100 ? "remainder" : "remainderf"; |
561 | exc.name = type < 100 ? "remainder" : "remainderf"; |
560 | exc.retval = zero/zero; |
562 | exc.retval = zero/zero; |
561 | if (_LIB_VERSION == _POSIX_) |
563 | if (_LIB_VERSION == _POSIX_) |
562 | errno = EDOM; |
564 | errno = EDOM; |
563 | else if (!matherr(&exc)) { |
565 | else if (!matherr(&exc)) { |
564 | if (_LIB_VERSION == _SVID_) { |
566 | if (_LIB_VERSION == _SVID_) { |
565 | (void) WRITE2("remainder: DOMAIN error\n", 24); |
567 | (void) WRITE2("remainder: DOMAIN error\n", 24); |
566 | } |
568 | } |
567 | errno = EDOM; |
569 | errno = EDOM; |
568 | } |
570 | } |
569 | break; |
571 | break; |
570 | case 29: |
572 | case 29: |
571 | case 129: |
573 | case 129: |
572 | /* acosh(x<1) */ |
574 | /* acosh(x<1) */ |
573 | exc.type = DOMAIN; |
575 | exc.type = DOMAIN; |
574 | exc.name = type < 100 ? "acosh" : "acoshf"; |
576 | exc.name = type < 100 ? "acosh" : "acoshf"; |
575 | exc.retval = zero/zero; |
577 | exc.retval = zero/zero; |
576 | if (_LIB_VERSION == _POSIX_) |
578 | if (_LIB_VERSION == _POSIX_) |
577 | errno = EDOM; |
579 | errno = EDOM; |
578 | else if (!matherr(&exc)) { |
580 | else if (!matherr(&exc)) { |
579 | if (_LIB_VERSION == _SVID_) { |
581 | if (_LIB_VERSION == _SVID_) { |
580 | (void) WRITE2("acosh: DOMAIN error\n", 20); |
582 | (void) WRITE2("acosh: DOMAIN error\n", 20); |
581 | } |
583 | } |
582 | errno = EDOM; |
584 | errno = EDOM; |
583 | } |
585 | } |
584 | break; |
586 | break; |
585 | case 30: |
587 | case 30: |
586 | case 130: |
588 | case 130: |
587 | /* atanh(|x|>1) */ |
589 | /* atanh(|x|>1) */ |
588 | exc.type = DOMAIN; |
590 | exc.type = DOMAIN; |
589 | exc.name = type < 100 ? "atanh" : "atanhf"; |
591 | exc.name = type < 100 ? "atanh" : "atanhf"; |
590 | exc.retval = zero/zero; |
592 | exc.retval = zero/zero; |
591 | if (_LIB_VERSION == _POSIX_) |
593 | if (_LIB_VERSION == _POSIX_) |
592 | errno = EDOM; |
594 | errno = EDOM; |
593 | else if (!matherr(&exc)) { |
595 | else if (!matherr(&exc)) { |
594 | if (_LIB_VERSION == _SVID_) { |
596 | if (_LIB_VERSION == _SVID_) { |
595 | (void) WRITE2("atanh: DOMAIN error\n", 20); |
597 | (void) WRITE2("atanh: DOMAIN error\n", 20); |
596 | } |
598 | } |
597 | errno = EDOM; |
599 | errno = EDOM; |
598 | } |
600 | } |
599 | break; |
601 | break; |
600 | case 31: |
602 | case 31: |
601 | case 131: |
603 | case 131: |
602 | /* atanh(|x|=1) */ |
604 | /* atanh(|x|=1) */ |
603 | exc.type = SING; |
605 | exc.type = SING; |
604 | exc.name = type < 100 ? "atanh" : "atanhf"; |
606 | exc.name = type < 100 ? "atanh" : "atanhf"; |
605 | exc.retval = x/zero; /* sign(x)*inf */ |
607 | exc.retval = x/zero; /* sign(x)*inf */ |
606 | if (_LIB_VERSION == _POSIX_) |
608 | if (_LIB_VERSION == _POSIX_) |
607 | errno = EDOM; |
609 | errno = EDOM; |
608 | else if (!matherr(&exc)) { |
610 | else if (!matherr(&exc)) { |
609 | if (_LIB_VERSION == _SVID_) { |
611 | if (_LIB_VERSION == _SVID_) { |
610 | (void) WRITE2("atanh: SING error\n", 18); |
612 | (void) WRITE2("atanh: SING error\n", 18); |
611 | } |
613 | } |
612 | errno = EDOM; |
614 | errno = EDOM; |
613 | } |
615 | } |
614 | break; |
616 | break; |
615 | case 32: |
617 | case 32: |
616 | case 132: |
618 | case 132: |
617 | /* scalb overflow; SVID also returns +-HUGE_VAL */ |
619 | /* scalb overflow; SVID also returns +-HUGE_VAL */ |
618 | exc.type = OVERFLOW; |
620 | exc.type = OVERFLOW; |
619 | exc.name = type < 100 ? "scalb" : "scalbf"; |
621 | exc.name = type < 100 ? "scalb" : "scalbf"; |
620 | exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; |
622 | exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; |
621 | if (_LIB_VERSION == _POSIX_) |
623 | if (_LIB_VERSION == _POSIX_) |
622 | errno = ERANGE; |
624 | errno = ERANGE; |
623 | else if (!matherr(&exc)) { |
625 | else if (!matherr(&exc)) { |
624 | errno = ERANGE; |
626 | errno = ERANGE; |
625 | } |
627 | } |
626 | break; |
628 | break; |
627 | case 33: |
629 | case 33: |
628 | case 133: |
630 | case 133: |
629 | /* scalb underflow */ |
631 | /* scalb underflow */ |
630 | exc.type = UNDERFLOW; |
632 | exc.type = UNDERFLOW; |
631 | exc.name = type < 100 ? "scalb" : "scalbf"; |
633 | exc.name = type < 100 ? "scalb" : "scalbf"; |
632 | exc.retval = copysign(zero,x); |
634 | exc.retval = copysign(zero,x); |
633 | if (_LIB_VERSION == _POSIX_) |
635 | if (_LIB_VERSION == _POSIX_) |
634 | errno = ERANGE; |
636 | errno = ERANGE; |
635 | else if (!matherr(&exc)) { |
637 | else if (!matherr(&exc)) { |
636 | errno = ERANGE; |
638 | errno = ERANGE; |
637 | } |
639 | } |
638 | break; |
640 | break; |
639 | case 34: |
641 | case 34: |
640 | case 134: |
642 | case 134: |
641 | /* j0(|x|>X_TLOSS) */ |
643 | /* j0(|x|>X_TLOSS) */ |
642 | exc.type = TLOSS; |
644 | exc.type = TLOSS; |
643 | exc.name = type < 100 ? "j0" : "j0f"; |
645 | exc.name = type < 100 ? "j0" : "j0f"; |
644 | exc.retval = zero; |
646 | exc.retval = zero; |
645 | if (_LIB_VERSION == _POSIX_) |
647 | if (_LIB_VERSION == _POSIX_) |
646 | errno = ERANGE; |
648 | errno = ERANGE; |
647 | else if (!matherr(&exc)) { |
649 | else if (!matherr(&exc)) { |
648 | if (_LIB_VERSION == _SVID_) { |
650 | if (_LIB_VERSION == _SVID_) { |
649 | (void) WRITE2(exc.name, 2); |
651 | (void) WRITE2(exc.name, 2); |
650 | (void) WRITE2(": TLOSS error\n", 14); |
652 | (void) WRITE2(": TLOSS error\n", 14); |
651 | } |
653 | } |
652 | errno = ERANGE; |
654 | errno = ERANGE; |
653 | } |
655 | } |
654 | break; |
656 | break; |
655 | case 35: |
657 | case 35: |
656 | case 135: |
658 | case 135: |
657 | /* y0(x>X_TLOSS) */ |
659 | /* y0(x>X_TLOSS) */ |
658 | exc.type = TLOSS; |
660 | exc.type = TLOSS; |
659 | exc.name = type < 100 ? "y0" : "y0f"; |
661 | exc.name = type < 100 ? "y0" : "y0f"; |
660 | exc.retval = zero; |
662 | exc.retval = zero; |
661 | if (_LIB_VERSION == _POSIX_) |
663 | if (_LIB_VERSION == _POSIX_) |
662 | errno = ERANGE; |
664 | errno = ERANGE; |
663 | else if (!matherr(&exc)) { |
665 | else if (!matherr(&exc)) { |
664 | if (_LIB_VERSION == _SVID_) { |
666 | if (_LIB_VERSION == _SVID_) { |
665 | (void) WRITE2(exc.name, 2); |
667 | (void) WRITE2(exc.name, 2); |
666 | (void) WRITE2(": TLOSS error\n", 14); |
668 | (void) WRITE2(": TLOSS error\n", 14); |
667 | } |
669 | } |
668 | errno = ERANGE; |
670 | errno = ERANGE; |
669 | } |
671 | } |
670 | break; |
672 | break; |
671 | case 36: |
673 | case 36: |
672 | case 136: |
674 | case 136: |
673 | /* j1(|x|>X_TLOSS) */ |
675 | /* j1(|x|>X_TLOSS) */ |
674 | exc.type = TLOSS; |
676 | exc.type = TLOSS; |
675 | exc.name = type < 100 ? "j1" : "j1f"; |
677 | exc.name = type < 100 ? "j1" : "j1f"; |
676 | exc.retval = zero; |
678 | exc.retval = zero; |
677 | if (_LIB_VERSION == _POSIX_) |
679 | if (_LIB_VERSION == _POSIX_) |
678 | errno = ERANGE; |
680 | errno = ERANGE; |
679 | else if (!matherr(&exc)) { |
681 | else if (!matherr(&exc)) { |
680 | if (_LIB_VERSION == _SVID_) { |
682 | if (_LIB_VERSION == _SVID_) { |
681 | (void) WRITE2(exc.name, 2); |
683 | (void) WRITE2(exc.name, 2); |
682 | (void) WRITE2(": TLOSS error\n", 14); |
684 | (void) WRITE2(": TLOSS error\n", 14); |
683 | } |
685 | } |
684 | errno = ERANGE; |
686 | errno = ERANGE; |
685 | } |
687 | } |
686 | break; |
688 | break; |
687 | case 37: |
689 | case 37: |
688 | case 137: |
690 | case 137: |
689 | /* y1(x>X_TLOSS) */ |
691 | /* y1(x>X_TLOSS) */ |
690 | exc.type = TLOSS; |
692 | exc.type = TLOSS; |
691 | exc.name = type < 100 ? "y1" : "y1f"; |
693 | exc.name = type < 100 ? "y1" : "y1f"; |
692 | exc.retval = zero; |
694 | exc.retval = zero; |
693 | if (_LIB_VERSION == _POSIX_) |
695 | if (_LIB_VERSION == _POSIX_) |
694 | errno = ERANGE; |
696 | errno = ERANGE; |
695 | else if (!matherr(&exc)) { |
697 | else if (!matherr(&exc)) { |
696 | if (_LIB_VERSION == _SVID_) { |
698 | if (_LIB_VERSION == _SVID_) { |
697 | (void) WRITE2(exc.name, 2); |
699 | (void) WRITE2(exc.name, 2); |
698 | (void) WRITE2(": TLOSS error\n", 14); |
700 | (void) WRITE2(": TLOSS error\n", 14); |
699 | } |
701 | } |
700 | errno = ERANGE; |
702 | errno = ERANGE; |
701 | } |
703 | } |
702 | break; |
704 | break; |
703 | case 38: |
705 | case 38: |
704 | case 138: |
706 | case 138: |
705 | /* jn(|x|>X_TLOSS) */ |
707 | /* jn(|x|>X_TLOSS) */ |
706 | exc.type = TLOSS; |
708 | exc.type = TLOSS; |
707 | exc.name = type < 100 ? "jn" : "jnf"; |
709 | exc.name = type < 100 ? "jn" : "jnf"; |
708 | exc.retval = zero; |
710 | exc.retval = zero; |
709 | if (_LIB_VERSION == _POSIX_) |
711 | if (_LIB_VERSION == _POSIX_) |
710 | errno = ERANGE; |
712 | errno = ERANGE; |
711 | else if (!matherr(&exc)) { |
713 | else if (!matherr(&exc)) { |
712 | if (_LIB_VERSION == _SVID_) { |
714 | if (_LIB_VERSION == _SVID_) { |
713 | (void) WRITE2(exc.name, 2); |
715 | (void) WRITE2(exc.name, 2); |
714 | (void) WRITE2(": TLOSS error\n", 14); |
716 | (void) WRITE2(": TLOSS error\n", 14); |
715 | } |
717 | } |
716 | errno = ERANGE; |
718 | errno = ERANGE; |
717 | } |
719 | } |
718 | break; |
720 | break; |
719 | case 39: |
721 | case 39: |
720 | case 139: |
722 | case 139: |
721 | /* yn(x>X_TLOSS) */ |
723 | /* yn(x>X_TLOSS) */ |
722 | exc.type = TLOSS; |
724 | exc.type = TLOSS; |
723 | exc.name = type < 100 ? "yn" : "ynf"; |
725 | exc.name = type < 100 ? "yn" : "ynf"; |
724 | exc.retval = zero; |
726 | exc.retval = zero; |
725 | if (_LIB_VERSION == _POSIX_) |
727 | if (_LIB_VERSION == _POSIX_) |
726 | errno = ERANGE; |
728 | errno = ERANGE; |
727 | else if (!matherr(&exc)) { |
729 | else if (!matherr(&exc)) { |
728 | if (_LIB_VERSION == _SVID_) { |
730 | if (_LIB_VERSION == _SVID_) { |
729 | (void) WRITE2(exc.name, 2); |
731 | (void) WRITE2(exc.name, 2); |
730 | (void) WRITE2(": TLOSS error\n", 14); |
732 | (void) WRITE2(": TLOSS error\n", 14); |
731 | } |
733 | } |
732 | errno = ERANGE; |
734 | errno = ERANGE; |
733 | } |
735 | } |
734 | break; |
736 | break; |
735 | case 40: |
737 | case 40: |
736 | case 140: |
738 | case 140: |
737 | /* gamma(finite) overflow */ |
739 | /* gamma(finite) overflow */ |
738 | exc.type = OVERFLOW; |
740 | exc.type = OVERFLOW; |
739 | exc.name = type < 100 ? "gamma" : "gammaf"; |
741 | exc.name = type < 100 ? "gamma" : "gammaf"; |
740 | if (_LIB_VERSION == _SVID_) |
742 | if (_LIB_VERSION == _SVID_) |
741 | exc.retval = HUGE_VAL; |
743 | exc.retval = HUGE_VAL; |
742 | else |
744 | else |
743 | exc.retval = HUGE_VAL; |
745 | exc.retval = HUGE_VAL; |
744 | if (_LIB_VERSION == _POSIX_) |
746 | if (_LIB_VERSION == _POSIX_) |
745 | errno = ERANGE; |
747 | errno = ERANGE; |
746 | else if (!matherr(&exc)) { |
748 | else if (!matherr(&exc)) { |
747 | errno = ERANGE; |
749 | errno = ERANGE; |
748 | } |
750 | } |
749 | break; |
751 | break; |
750 | case 41: |
752 | case 41: |
751 | case 141: |
753 | case 141: |
752 | /* gamma(-integer) or gamma(0) */ |
754 | /* gamma(-integer) or gamma(0) */ |
753 | exc.type = SING; |
755 | exc.type = SING; |
754 | exc.name = type < 100 ? "gamma" : "gammaf"; |
756 | exc.name = type < 100 ? "gamma" : "gammaf"; |
755 | if (_LIB_VERSION == _SVID_) |
757 | if (_LIB_VERSION == _SVID_) |
756 | exc.retval = HUGE_VAL; |
758 | exc.retval = HUGE_VAL; |
757 | else |
759 | else |
758 | exc.retval = HUGE_VAL; |
760 | exc.retval = HUGE_VAL; |
759 | if (_LIB_VERSION == _POSIX_) |
761 | if (_LIB_VERSION == _POSIX_) |
760 | errno = EDOM; |
762 | errno = EDOM; |
761 | else if (!matherr(&exc)) { |
763 | else if (!matherr(&exc)) { |
762 | if (_LIB_VERSION == _SVID_) { |
764 | if (_LIB_VERSION == _SVID_) { |
763 | (void) WRITE2("gamma: SING error\n", 18); |
765 | (void) WRITE2("gamma: SING error\n", 18); |
764 | } |
766 | } |
765 | errno = EDOM; |
767 | errno = EDOM; |
766 | } |
768 | } |
767 | break; |
769 | break; |
768 | case 42: |
770 | case 42: |
769 | case 142: |
771 | case 142: |
770 | /* pow(NaN,0.0) */ |
772 | /* pow(NaN,0.0) */ |
771 | /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ |
773 | /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ |
772 | exc.type = DOMAIN; |
774 | exc.type = DOMAIN; |
773 | exc.name = type < 100 ? "pow" : "powf"; |
775 | exc.name = type < 100 ? "pow" : "powf"; |
774 | exc.retval = x; |
776 | exc.retval = x; |
775 | if (_LIB_VERSION == _IEEE_ || |
777 | if (_LIB_VERSION == _IEEE_ || |
776 | _LIB_VERSION == _POSIX_) exc.retval = 1.0; |
778 | _LIB_VERSION == _POSIX_) exc.retval = 1.0; |
777 | else if (!matherr(&exc)) { |
779 | else if (!matherr(&exc)) { |
778 | errno = EDOM; |
780 | errno = EDOM; |
779 | } |
781 | } |
780 | break; |
782 | break; |
781 | } |
783 | } |
782 | return exc.retval; |
784 | return exc.retval; |
783 | }>>>>>>>>>>>>>>1)>>>>0)>>>>>>>>0)>>>0)>>>>>0)>>>0)>>>0)>>>>>>>>>1) |
785 | }>>>>>>>>>>>>>>1)>>>>0)>>>>>>>>0)>>>0)>>>>>0)>>>0)>>>0)>>>>>>>>>1) |
784 | >0) |
786 | >0) |
785 | >0) |
787 | >0) |
786 | > |
788 | > |