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