* sysdeps/unix/sysv/linux/m68k/sysdep.h (INLINE_SYSCALL): Don't
[glibc.git] / sysdeps / ieee754 / k_standard.c
blob6def34bc0c72e7546b587d1ac48714bea8c08f16
1 /* @(#)k_standard.c 5.1 93/09/24 */
2 /*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
13 #if defined(LIBM_SCCS) && !defined(lint)
14 static char rcsid[] = "$NetBSD: k_standard.c,v 1.6 1995/05/10 20:46:35 jtc Exp $";
15 #endif
17 #include "math.h"
18 #include "math_private.h"
19 #include <errno.h>
21 #include <assert.h>
23 #ifndef _USE_WRITE
24 #include <stdio.h> /* fputs(), stderr */
25 #define WRITE2(u,v) fputs(u, stderr)
26 #else /* !defined(_USE_WRITE) */
27 #include <unistd.h> /* write */
28 #define WRITE2(u,v) write(2, u, v)
29 #undef fflush
30 #endif /* !defined(_USE_WRITE) */
32 /* XXX gcc versions until now don't delay the 0.0/0.0 division until
33 runtime but produce NaN at copile time. This is wrong since the
34 exceptions are not set correctly. */
35 #if 0 && defined __STDC__
36 static const double zero = 0.0; /* used as const */
37 #else
38 static double zero = 0.0; /* used as const */
39 #endif
42 * Standard conformance (non-IEEE) on exception cases.
43 * Mapping:
44 * 1 -- acos(|x|>1)
45 * 2 -- asin(|x|>1)
46 * 3 -- atan2(+-0,+-0)
47 * 4 -- hypot overflow
48 * 5 -- cosh overflow
49 * 6 -- exp overflow
50 * 7 -- exp underflow
51 * 8 -- y0(0)
52 * 9 -- y0(-ve)
53 * 10-- y1(0)
54 * 11-- y1(-ve)
55 * 12-- yn(0)
56 * 13-- yn(-ve)
57 * 14-- lgamma(finite) overflow
58 * 15-- lgamma(-integer)
59 * 16-- log(0)
60 * 17-- log(x<0)
61 * 18-- log10(0)
62 * 19-- log10(x<0)
63 * 20-- pow(0.0,0.0)
64 * 21-- pow(x,y) overflow
65 * 22-- pow(x,y) underflow
66 * 23-- pow(0,negative)
67 * 24-- pow(neg,non-integral)
68 * 25-- sinh(finite) overflow
69 * 26-- sqrt(negative)
70 * 27-- fmod(x,0)
71 * 28-- remainder(x,0)
72 * 29-- acosh(x<1)
73 * 30-- atanh(|x|>1)
74 * 31-- atanh(|x|=1)
75 * 32-- scalb overflow
76 * 33-- scalb underflow
77 * 34-- j0(|x|>X_TLOSS)
78 * 35-- y0(x>X_TLOSS)
79 * 36-- j1(|x|>X_TLOSS)
80 * 37-- y1(x>X_TLOSS)
81 * 38-- jn(|x|>X_TLOSS, n)
82 * 39-- yn(x>X_TLOSS, n)
83 * 40-- tgamma(finite) overflow
84 * 41-- tgamma(-integer)
85 * 42-- pow(NaN,0.0)
86 * 43-- +0**neg
87 * 44-- exp2 overflow
88 * 45-- exp2 underflow
89 * 46-- exp10 overflow
90 * 47-- exp10 underflow
91 * 48-- log2(0)
92 * 49-- log2(x<0)
96 #ifdef __STDC__
97 double __kernel_standard(double x, double y, int type)
98 #else
99 double __kernel_standard(x,y,type)
100 double x,y; int type;
101 #endif
103 struct exception exc;
104 #ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */
105 #define HUGE_VAL inf
106 double inf = 0.0;
108 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
109 #endif
111 #ifdef _USE_WRITE
112 (void) fflush(stdout);
113 #endif
114 exc.arg1 = x;
115 exc.arg2 = y;
116 switch(type) {
117 case 1:
118 case 101:
119 case 201:
120 /* acos(|x|>1) */
121 exc.type = DOMAIN;
122 exc.name = type < 100 ? "acos" : (type < 200
123 ? "acosf" : "acosl");;
124 if (_LIB_VERSION == _SVID_)
125 exc.retval = HUGE;
126 else
127 exc.retval = NAN;
128 if (_LIB_VERSION == _POSIX_)
129 __set_errno (EDOM);
130 else if (!matherr(&exc)) {
131 if(_LIB_VERSION == _SVID_) {
132 (void) WRITE2("acos: DOMAIN error\n", 19);
134 __set_errno (EDOM);
136 break;
137 case 2:
138 case 102:
139 case 202:
140 /* asin(|x|>1) */
141 exc.type = DOMAIN;
142 exc.name = type < 100 ? "asin" : (type < 200
143 ? "asinf" : "asinl");
144 if (_LIB_VERSION == _SVID_)
145 exc.retval = HUGE;
146 else
147 exc.retval = NAN;
148 if(_LIB_VERSION == _POSIX_)
149 __set_errno (EDOM);
150 else if (!matherr(&exc)) {
151 if(_LIB_VERSION == _SVID_) {
152 (void) WRITE2("asin: DOMAIN error\n", 19);
154 __set_errno (EDOM);
156 break;
157 case 3:
158 case 103:
159 case 203:
160 /* atan2(+-0,+-0) */
161 exc.arg1 = y;
162 exc.arg2 = x;
163 exc.type = DOMAIN;
164 exc.name = type < 100 ? "atan2" : (type < 200
165 ? "atan2f" : "atan2l");
166 assert (_LIB_VERSION == _SVID_);
167 exc.retval = HUGE;
168 if(_LIB_VERSION == _POSIX_)
169 __set_errno (EDOM);
170 else if (!matherr(&exc)) {
171 if(_LIB_VERSION == _SVID_) {
172 (void) WRITE2("atan2: DOMAIN error\n", 20);
174 __set_errno (EDOM);
176 break;
177 case 4:
178 case 104:
179 case 204:
180 /* hypot(finite,finite) overflow */
181 exc.type = OVERFLOW;
182 exc.name = type < 100 ? "hypot" : (type < 200
183 ? "hypotf" : "hypotl");
184 if (_LIB_VERSION == _SVID_)
185 exc.retval = HUGE;
186 else
187 exc.retval = HUGE_VAL;
188 if (_LIB_VERSION == _POSIX_)
189 __set_errno (ERANGE);
190 else if (!matherr(&exc)) {
191 __set_errno (ERANGE);
193 break;
194 case 5:
195 case 105:
196 case 205:
197 /* cosh(finite) overflow */
198 exc.type = OVERFLOW;
199 exc.name = type < 100 ? "cosh" : (type < 200
200 ? "coshf" : "coshl");
201 if (_LIB_VERSION == _SVID_)
202 exc.retval = HUGE;
203 else
204 exc.retval = HUGE_VAL;
205 if (_LIB_VERSION == _POSIX_)
206 __set_errno (ERANGE);
207 else if (!matherr(&exc)) {
208 __set_errno (ERANGE);
210 break;
211 case 6:
212 case 106:
213 case 206:
214 /* exp(finite) overflow */
215 exc.type = OVERFLOW;
216 exc.name = type < 100 ? "exp" : (type < 200
217 ? "expf" : "expl");
218 if (_LIB_VERSION == _SVID_)
219 exc.retval = HUGE;
220 else
221 exc.retval = HUGE_VAL;
222 if (_LIB_VERSION == _POSIX_)
223 __set_errno (ERANGE);
224 else if (!matherr(&exc)) {
225 __set_errno (ERANGE);
227 break;
228 case 7:
229 case 107:
230 case 207:
231 /* exp(finite) underflow */
232 exc.type = UNDERFLOW;
233 exc.name = type < 100 ? "exp" : (type < 200
234 ? "expf" : "expl");
235 exc.retval = zero;
236 if (_LIB_VERSION == _POSIX_)
237 __set_errno (ERANGE);
238 else if (!matherr(&exc)) {
239 __set_errno (ERANGE);
241 break;
242 case 8:
243 case 108:
244 case 208:
245 /* y0(0) = -inf */
246 exc.type = DOMAIN; /* should be SING for IEEE */
247 exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l");
248 if (_LIB_VERSION == _SVID_)
249 exc.retval = -HUGE;
250 else
251 exc.retval = -HUGE_VAL;
252 if (_LIB_VERSION == _POSIX_)
253 __set_errno (EDOM);
254 else if (!matherr(&exc)) {
255 if (_LIB_VERSION == _SVID_) {
256 (void) WRITE2("y0: DOMAIN error\n", 17);
258 __set_errno (EDOM);
260 break;
261 case 9:
262 case 109:
263 case 209:
264 /* y0(x<0) = NaN */
265 exc.type = DOMAIN;
266 exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l");
267 if (_LIB_VERSION == _SVID_)
268 exc.retval = -HUGE;
269 else
270 exc.retval = -HUGE_VAL;
271 if (_LIB_VERSION == _POSIX_)
272 __set_errno (EDOM);
273 else if (!matherr(&exc)) {
274 if (_LIB_VERSION == _SVID_) {
275 (void) WRITE2("y0: DOMAIN error\n", 17);
277 __set_errno (EDOM);
279 break;
280 case 10:
281 case 110:
282 case 210:
283 /* y1(0) = -inf */
284 exc.type = DOMAIN; /* should be SING for IEEE */
285 exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l");
286 if (_LIB_VERSION == _SVID_)
287 exc.retval = -HUGE;
288 else
289 exc.retval = -HUGE_VAL;
290 if (_LIB_VERSION == _POSIX_)
291 __set_errno (EDOM);
292 else if (!matherr(&exc)) {
293 if (_LIB_VERSION == _SVID_) {
294 (void) WRITE2("y1: DOMAIN error\n", 17);
296 __set_errno (EDOM);
298 break;
299 case 11:
300 case 111:
301 case 211:
302 /* y1(x<0) = NaN */
303 exc.type = DOMAIN;
304 exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l");
305 if (_LIB_VERSION == _SVID_)
306 exc.retval = -HUGE;
307 else
308 exc.retval = -HUGE_VAL;
309 if (_LIB_VERSION == _POSIX_)
310 __set_errno (EDOM);
311 else if (!matherr(&exc)) {
312 if (_LIB_VERSION == _SVID_) {
313 (void) WRITE2("y1: DOMAIN error\n", 17);
315 __set_errno (EDOM);
317 break;
318 case 12:
319 case 112:
320 case 212:
321 /* yn(n,0) = -inf */
322 exc.type = DOMAIN; /* should be SING for IEEE */
323 exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl");
324 if (_LIB_VERSION == _SVID_)
325 exc.retval = -HUGE;
326 else
327 exc.retval = -HUGE_VAL;
328 if (_LIB_VERSION == _POSIX_)
329 __set_errno (EDOM);
330 else if (!matherr(&exc)) {
331 if (_LIB_VERSION == _SVID_) {
332 (void) WRITE2("yn: DOMAIN error\n", 17);
334 __set_errno (EDOM);
336 break;
337 case 13:
338 case 113:
339 case 213:
340 /* yn(x<0) = NaN */
341 exc.type = DOMAIN;
342 exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl");
343 if (_LIB_VERSION == _SVID_)
344 exc.retval = -HUGE;
345 else
346 exc.retval = -HUGE_VAL;
347 if (_LIB_VERSION == _POSIX_)
348 __set_errno (EDOM);
349 else if (!matherr(&exc)) {
350 if (_LIB_VERSION == _SVID_) {
351 (void) WRITE2("yn: DOMAIN error\n", 17);
353 __set_errno (EDOM);
355 break;
356 case 14:
357 case 114:
358 case 214:
359 /* lgamma(finite) overflow */
360 exc.type = OVERFLOW;
361 exc.name = type < 100 ? "lgamma" : (type < 200
362 ? "lgammaf" : "lgammal");
363 if (_LIB_VERSION == _SVID_)
364 exc.retval = HUGE;
365 else
366 exc.retval = HUGE_VAL;
367 if (_LIB_VERSION == _POSIX_)
368 __set_errno (ERANGE);
369 else if (!matherr(&exc)) {
370 __set_errno (ERANGE);
372 break;
373 case 15:
374 case 115:
375 case 215:
376 /* lgamma(-integer) or lgamma(0) */
377 exc.type = SING;
378 exc.name = type < 100 ? "lgamma" : (type < 200
379 ? "lgammaf" : "lgammal");
380 if (_LIB_VERSION == _SVID_)
381 exc.retval = HUGE;
382 else
383 exc.retval = HUGE_VAL;
384 if (_LIB_VERSION == _POSIX_)
385 __set_errno (EDOM);
386 else if (!matherr(&exc)) {
387 if (_LIB_VERSION == _SVID_) {
388 (void) WRITE2("lgamma: SING error\n", 19);
390 __set_errno (EDOM);
392 break;
393 case 16:
394 case 116:
395 case 216:
396 /* log(0) */
397 exc.type = SING;
398 exc.name = type < 100 ? "log" : (type < 200 ? "logf" : "logl");
399 if (_LIB_VERSION == _SVID_)
400 exc.retval = -HUGE;
401 else
402 exc.retval = -HUGE_VAL;
403 if (_LIB_VERSION == _POSIX_)
404 __set_errno (ERANGE);
405 else if (!matherr(&exc)) {
406 if (_LIB_VERSION == _SVID_) {
407 (void) WRITE2("log: SING error\n", 16);
409 __set_errno (EDOM);
411 break;
412 case 17:
413 case 117:
414 case 217:
415 /* log(x<0) */
416 exc.type = DOMAIN;
417 exc.name = type < 100 ? "log" : (type < 200 ? "logf" : "logl");
418 if (_LIB_VERSION == _SVID_)
419 exc.retval = -HUGE;
420 else
421 exc.retval = NAN;
422 if (_LIB_VERSION == _POSIX_)
423 __set_errno (EDOM);
424 else if (!matherr(&exc)) {
425 if (_LIB_VERSION == _SVID_) {
426 (void) WRITE2("log: DOMAIN error\n", 18);
428 __set_errno (EDOM);
430 break;
431 case 18:
432 case 118:
433 case 218:
434 /* log10(0) */
435 exc.type = SING;
436 exc.name = type < 100 ? "log10" : (type < 200
437 ? "log10f" : "log10l");
438 if (_LIB_VERSION == _SVID_)
439 exc.retval = -HUGE;
440 else
441 exc.retval = -HUGE_VAL;
442 if (_LIB_VERSION == _POSIX_)
443 __set_errno (ERANGE);
444 else if (!matherr(&exc)) {
445 if (_LIB_VERSION == _SVID_) {
446 (void) WRITE2("log10: SING error\n", 18);
448 __set_errno (EDOM);
450 break;
451 case 19:
452 case 119:
453 case 219:
454 /* log10(x<0) */
455 exc.type = DOMAIN;
456 exc.name = type < 100 ? "log10" : (type < 200
457 ? "log10f" : "log10l");
458 if (_LIB_VERSION == _SVID_)
459 exc.retval = -HUGE;
460 else
461 exc.retval = NAN;
462 if (_LIB_VERSION == _POSIX_)
463 __set_errno (EDOM);
464 else if (!matherr(&exc)) {
465 if (_LIB_VERSION == _SVID_) {
466 (void) WRITE2("log10: DOMAIN error\n", 20);
468 __set_errno (EDOM);
470 break;
471 case 20:
472 case 120:
473 case 220:
474 /* pow(0.0,0.0) */
475 /* error only if _LIB_VERSION == _SVID_ */
476 exc.type = DOMAIN;
477 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
478 exc.retval = zero;
479 if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
480 else if (!matherr(&exc)) {
481 (void) WRITE2("pow(0,0): DOMAIN error\n", 23);
482 __set_errno (EDOM);
484 break;
485 case 21:
486 case 121:
487 case 221:
488 /* pow(x,y) overflow */
489 exc.type = OVERFLOW;
490 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
491 if (_LIB_VERSION == _SVID_) {
492 exc.retval = HUGE;
493 y *= 0.5;
494 if(x<zero&&__rint(y)!=y) exc.retval = -HUGE;
495 } else {
496 exc.retval = HUGE_VAL;
497 y *= 0.5;
498 if(x<zero&&__rint(y)!=y) exc.retval = -HUGE_VAL;
500 if (_LIB_VERSION == _POSIX_)
501 __set_errno (ERANGE);
502 else if (!matherr(&exc)) {
503 __set_errno (ERANGE);
505 break;
506 case 22:
507 case 122:
508 case 222:
509 /* pow(x,y) underflow */
510 exc.type = UNDERFLOW;
511 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
512 exc.retval = zero;
513 if (_LIB_VERSION == _POSIX_)
514 __set_errno (ERANGE);
515 else if (!matherr(&exc)) {
516 __set_errno (ERANGE);
518 break;
519 case 23:
520 case 123:
521 case 223:
522 /* -0**neg */
523 exc.type = DOMAIN;
524 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
525 if (_LIB_VERSION == _SVID_)
526 exc.retval = zero;
527 else
528 exc.retval = -HUGE_VAL;
529 if (_LIB_VERSION == _POSIX_)
530 __set_errno (EDOM);
531 else if (!matherr(&exc)) {
532 if (_LIB_VERSION == _SVID_) {
533 (void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
535 __set_errno (EDOM);
537 break;
538 case 43:
539 case 143:
540 case 243:
541 /* +0**neg */
542 exc.type = DOMAIN;
543 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
544 if (_LIB_VERSION == _SVID_)
545 exc.retval = zero;
546 else
547 exc.retval = HUGE_VAL;
548 if (_LIB_VERSION == _POSIX_)
549 __set_errno (EDOM);
550 else if (!matherr(&exc)) {
551 if (_LIB_VERSION == _SVID_) {
552 (void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
554 __set_errno (EDOM);
556 break;
557 case 24:
558 case 124:
559 case 224:
560 /* neg**non-integral */
561 exc.type = DOMAIN;
562 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
563 if (_LIB_VERSION == _SVID_)
564 exc.retval = zero;
565 else
566 exc.retval = zero/zero; /* X/Open allow NaN */
567 if (_LIB_VERSION == _POSIX_)
568 __set_errno (EDOM);
569 else if (!matherr(&exc)) {
570 if (_LIB_VERSION == _SVID_) {
571 (void) WRITE2("neg**non-integral: DOMAIN error\n", 32);
573 __set_errno (EDOM);
575 break;
576 case 25:
577 case 125:
578 case 225:
579 /* sinh(finite) overflow */
580 exc.type = OVERFLOW;
581 exc.name = type < 100 ? "sinh" : (type < 200
582 ? "sinhf" : "sinhl");
583 if (_LIB_VERSION == _SVID_)
584 exc.retval = ( (x>zero) ? HUGE : -HUGE);
585 else
586 exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL);
587 if (_LIB_VERSION == _POSIX_)
588 __set_errno (ERANGE);
589 else if (!matherr(&exc)) {
590 __set_errno (ERANGE);
592 break;
593 case 26:
594 case 126:
595 case 226:
596 /* sqrt(x<0) */
597 exc.type = DOMAIN;
598 exc.name = type < 100 ? "sqrt" : (type < 200
599 ? "sqrtf" : "sqrtl");
600 if (_LIB_VERSION == _SVID_)
601 exc.retval = zero;
602 else
603 exc.retval = zero/zero;
604 if (_LIB_VERSION == _POSIX_)
605 __set_errno (EDOM);
606 else if (!matherr(&exc)) {
607 if (_LIB_VERSION == _SVID_) {
608 (void) WRITE2("sqrt: DOMAIN error\n", 19);
610 __set_errno (EDOM);
612 break;
613 case 27:
614 case 127:
615 case 227:
616 /* fmod(x,0) */
617 exc.type = DOMAIN;
618 exc.name = type < 100 ? "fmod" : (type < 200
619 ? "fmodf" : "fmodl");
620 if (_LIB_VERSION == _SVID_)
621 exc.retval = x;
622 else
623 exc.retval = zero/zero;
624 if (_LIB_VERSION == _POSIX_)
625 __set_errno (EDOM);
626 else if (!matherr(&exc)) {
627 if (_LIB_VERSION == _SVID_) {
628 (void) WRITE2("fmod: DOMAIN error\n", 20);
630 __set_errno (EDOM);
632 break;
633 case 28:
634 case 128:
635 case 228:
636 /* remainder(x,0) */
637 exc.type = DOMAIN;
638 exc.name = type < 100 ? "remainder" : (type < 200
639 ? "remainderf"
640 : "remainderl");
641 exc.retval = zero/zero;
642 if (_LIB_VERSION == _POSIX_)
643 __set_errno (EDOM);
644 else if (!matherr(&exc)) {
645 if (_LIB_VERSION == _SVID_) {
646 (void) WRITE2("remainder: DOMAIN error\n", 24);
648 __set_errno (EDOM);
650 break;
651 case 29:
652 case 129:
653 case 229:
654 /* acosh(x<1) */
655 exc.type = DOMAIN;
656 exc.name = type < 100 ? "acosh" : (type < 200
657 ? "acoshf" : "acoshl");
658 exc.retval = zero/zero;
659 if (_LIB_VERSION == _POSIX_)
660 __set_errno (EDOM);
661 else if (!matherr(&exc)) {
662 if (_LIB_VERSION == _SVID_) {
663 (void) WRITE2("acosh: DOMAIN error\n", 20);
665 __set_errno (EDOM);
667 break;
668 case 30:
669 case 130:
670 case 230:
671 /* atanh(|x|>1) */
672 exc.type = DOMAIN;
673 exc.name = type < 100 ? "atanh" : (type < 200
674 ? "atanhf" : "atanhl");
675 exc.retval = zero/zero;
676 if (_LIB_VERSION == _POSIX_)
677 __set_errno (EDOM);
678 else if (!matherr(&exc)) {
679 if (_LIB_VERSION == _SVID_) {
680 (void) WRITE2("atanh: DOMAIN error\n", 20);
682 __set_errno (EDOM);
684 break;
685 case 31:
686 case 131:
687 case 231:
688 /* atanh(|x|=1) */
689 exc.type = SING;
690 exc.name = type < 100 ? "atanh" : (type < 200
691 ? "atanhf" : "atanhl");
692 exc.retval = x/zero; /* sign(x)*inf */
693 if (_LIB_VERSION == _POSIX_)
694 __set_errno (EDOM);
695 else if (!matherr(&exc)) {
696 if (_LIB_VERSION == _SVID_) {
697 (void) WRITE2("atanh: SING error\n", 18);
699 __set_errno (EDOM);
701 break;
702 case 32:
703 case 132:
704 case 232:
705 /* scalb overflow; SVID also returns +-HUGE_VAL */
706 exc.type = OVERFLOW;
707 exc.name = type < 100 ? "scalb" : (type < 200
708 ? "scalbf" : "scalbl");
709 exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
710 if (_LIB_VERSION == _POSIX_)
711 __set_errno (ERANGE);
712 else if (!matherr(&exc)) {
713 __set_errno (ERANGE);
715 break;
716 case 33:
717 case 133:
718 case 233:
719 /* scalb underflow */
720 exc.type = UNDERFLOW;
721 exc.name = type < 100 ? "scalb" : (type < 200
722 ? "scalbf" : "scalbl");
723 exc.retval = __copysign(zero,x);
724 if (_LIB_VERSION == _POSIX_)
725 __set_errno (ERANGE);
726 else if (!matherr(&exc)) {
727 __set_errno (ERANGE);
729 break;
730 case 34:
731 case 134:
732 case 234:
733 /* j0(|x|>X_TLOSS) */
734 exc.type = TLOSS;
735 exc.name = type < 100 ? "j0" : (type < 200 ? "j0f" : "j0l");
736 exc.retval = zero;
737 if (_LIB_VERSION == _POSIX_)
738 __set_errno (ERANGE);
739 else if (!matherr(&exc)) {
740 if (_LIB_VERSION == _SVID_) {
741 (void) WRITE2(exc.name, 2);
742 (void) WRITE2(": TLOSS error\n", 14);
744 __set_errno (ERANGE);
746 break;
747 case 35:
748 case 135:
749 case 235:
750 /* y0(x>X_TLOSS) */
751 exc.type = TLOSS;
752 exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l");
753 exc.retval = zero;
754 if (_LIB_VERSION == _POSIX_)
755 __set_errno (ERANGE);
756 else if (!matherr(&exc)) {
757 if (_LIB_VERSION == _SVID_) {
758 (void) WRITE2(exc.name, 2);
759 (void) WRITE2(": TLOSS error\n", 14);
761 __set_errno (ERANGE);
763 break;
764 case 36:
765 case 136:
766 case 236:
767 /* j1(|x|>X_TLOSS) */
768 exc.type = TLOSS;
769 exc.name = type < 100 ? "j1" : (type < 200 ? "j1f" : "j1l");
770 exc.retval = zero;
771 if (_LIB_VERSION == _POSIX_)
772 __set_errno (ERANGE);
773 else if (!matherr(&exc)) {
774 if (_LIB_VERSION == _SVID_) {
775 (void) WRITE2(exc.name, 2);
776 (void) WRITE2(": TLOSS error\n", 14);
778 __set_errno (ERANGE);
780 break;
781 case 37:
782 case 137:
783 case 237:
784 /* y1(x>X_TLOSS) */
785 exc.type = TLOSS;
786 exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l");
787 exc.retval = zero;
788 if (_LIB_VERSION == _POSIX_)
789 __set_errno (ERANGE);
790 else if (!matherr(&exc)) {
791 if (_LIB_VERSION == _SVID_) {
792 (void) WRITE2(exc.name, 2);
793 (void) WRITE2(": TLOSS error\n", 14);
795 __set_errno (ERANGE);
797 break;
798 case 38:
799 case 138:
800 case 238:
801 /* jn(|x|>X_TLOSS) */
802 exc.type = TLOSS;
803 exc.name = type < 100 ? "jn" : (type < 200 ? "jnf" : "jnl");
804 exc.retval = zero;
805 if (_LIB_VERSION == _POSIX_)
806 __set_errno (ERANGE);
807 else if (!matherr(&exc)) {
808 if (_LIB_VERSION == _SVID_) {
809 (void) WRITE2(exc.name, 2);
810 (void) WRITE2(": TLOSS error\n", 14);
812 __set_errno (ERANGE);
814 break;
815 case 39:
816 case 139:
817 case 239:
818 /* yn(x>X_TLOSS) */
819 exc.type = TLOSS;
820 exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl");
821 exc.retval = zero;
822 if (_LIB_VERSION == _POSIX_)
823 __set_errno (ERANGE);
824 else if (!matherr(&exc)) {
825 if (_LIB_VERSION == _SVID_) {
826 (void) WRITE2(exc.name, 2);
827 (void) WRITE2(": TLOSS error\n", 14);
829 __set_errno (ERANGE);
831 break;
832 case 40:
833 case 140:
834 case 240:
835 /* gamma(finite) overflow */
836 exc.type = OVERFLOW;
837 exc.name = type < 100 ? "tgamma" : (type < 200
838 ? "tgammaf" : "tgammal");
839 exc.retval = HUGE_VAL;
840 if (_LIB_VERSION == _POSIX_)
841 __set_errno (ERANGE);
842 else if (!matherr(&exc)) {
843 __set_errno (ERANGE);
845 break;
846 case 41:
847 case 141:
848 case 241:
849 /* gamma(-integer) or gamma(0) */
850 exc.type = SING;
851 exc.name = type < 100 ? "tgamma" : (type < 200
852 ? "tgammaf" : "tgammal");
853 exc.retval = NAN;
854 if (_LIB_VERSION == _POSIX_)
855 __set_errno (EDOM);
856 else if (!matherr(&exc)) {
857 if (_LIB_VERSION == _SVID_) {
858 (void) WRITE2("tgamma: SING error\n", 18);
859 exc.retval = HUGE_VAL;
861 __set_errno (EDOM);
863 break;
864 case 42:
865 case 142:
866 case 242:
867 /* pow(NaN,0.0) */
868 /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
869 exc.type = DOMAIN;
870 exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
871 exc.retval = x;
872 if (_LIB_VERSION == _IEEE_ ||
873 _LIB_VERSION == _POSIX_) exc.retval = 1.0;
874 else if (!matherr(&exc)) {
875 __set_errno (EDOM);
877 break;
879 case 44:
880 case 144:
881 case 244:
882 /* exp(finite) overflow */
883 exc.type = OVERFLOW;
884 exc.name = type < 100 ? "exp2" : (type < 200
885 ? "exp2f" : "exp2l");
886 if (_LIB_VERSION == _SVID_)
887 exc.retval = HUGE;
888 else
889 exc.retval = HUGE_VAL;
890 if (_LIB_VERSION == _POSIX_)
891 __set_errno (ERANGE);
892 else if (!matherr(&exc)) {
893 __set_errno (ERANGE);
895 break;
896 case 45:
897 case 145:
898 case 245:
899 /* exp(finite) underflow */
900 exc.type = UNDERFLOW;
901 exc.name = type < 100 ? "exp2" : (type < 200
902 ? "exp2f" : "exp2l");
903 exc.retval = zero;
904 if (_LIB_VERSION == _POSIX_)
905 __set_errno (ERANGE);
906 else if (!matherr(&exc)) {
907 __set_errno (ERANGE);
909 break;
911 case 46:
912 case 146:
913 case 246:
914 /* exp(finite) overflow */
915 exc.type = OVERFLOW;
916 exc.name = type < 100 ? "exp10" : (type < 200
917 ? "exp10f" : "exp10l");
918 if (_LIB_VERSION == _SVID_)
919 exc.retval = HUGE;
920 else
921 exc.retval = HUGE_VAL;
922 if (_LIB_VERSION == _POSIX_)
923 __set_errno (ERANGE);
924 else if (!matherr(&exc)) {
925 __set_errno (ERANGE);
927 break;
928 case 47:
929 case 147:
930 case 247:
931 /* exp(finite) underflow */
932 exc.type = UNDERFLOW;
933 exc.name = type < 100 ? "exp10" : (type < 200
934 ? "exp10f" : "exp10l");
935 exc.retval = zero;
936 if (_LIB_VERSION == _POSIX_)
937 __set_errno (ERANGE);
938 else if (!matherr(&exc)) {
939 __set_errno (ERANGE);
941 break;
942 case 48:
943 case 148:
944 case 248:
945 /* log2(0) */
946 exc.type = SING;
947 exc.name = type < 100 ? "log2" : (type < 200
948 ? "log2f" : "log2l");
949 if (_LIB_VERSION == _SVID_)
950 exc.retval = -HUGE;
951 else
952 exc.retval = -HUGE_VAL;
953 if (_LIB_VERSION == _POSIX_)
954 __set_errno (ERANGE);
955 else if (!matherr(&exc)) {
956 __set_errno (EDOM);
958 break;
959 case 49:
960 case 149:
961 case 249:
962 /* log2(x<0) */
963 exc.type = DOMAIN;
964 exc.name = type < 100 ? "log2" : (type < 200
965 ? "log2f" : "log2l");
966 if (_LIB_VERSION == _SVID_)
967 exc.retval = -HUGE;
968 else
969 exc.retval = NAN;
970 if (_LIB_VERSION == _POSIX_)
971 __set_errno (EDOM);
972 else if (!matherr(&exc)) {
973 __set_errno (EDOM);
975 break;
977 /* #### Last used is 49/149/249 ### */
979 return exc.retval;