base/math/k_standard.c

Go to the documentation of this file.
00001 /* @(#)k_standard.c 5.1 93/09/24 */ 00002 /* 00003 * ==================================================== 00004 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 00005 * 00006 * Developed at SunPro, a Sun Microsystems, Inc. business. 00007 * Permission to use, copy, modify, and distribute this 00008 * software is freely granted, provided that this notice 00009 * is preserved. 00010 * ==================================================== 00011 */ 00012 00013 #if defined(LIBM_SCCS) && !defined(lint) 00014 static char rcsid[] = "$NetBSD: k_standard.c,v 1.6 1995/05/10 20:46:35 jtc Exp $"; 00015 #endif 00016 00017 #include "math.h" 00018 #include "mathP.h" 00019 #include <linux/errno.h> /* FIXME */ 00020 00021 extern int libm_errno; 00022 00023 extern int printk(const char *, ...); 00024 00025 #define WRITE2(u,v) printk("%.*s",v,u) 00026 00027 #ifdef __STDC__ 00028 static const double zero = 0.0; /* used as const */ 00029 #else 00030 static double zero = 0.0; /* used as const */ 00031 #endif 00032 00033 /* 00034 * Standard conformance (non-IEEE) on exception cases. 00035 * Mapping: 00036 * 1 -- acos(|x|>1) 00037 * 2 -- asin(|x|>1) 00038 * 3 -- atan2(+-0,+-0) 00039 * 4 -- hypot overflow 00040 * 5 -- cosh overflow 00041 * 6 -- exp overflow 00042 * 7 -- exp underflow 00043 * 8 -- y0(0) 00044 * 9 -- y0(-ve) 00045 * 10-- y1(0) 00046 * 11-- y1(-ve) 00047 * 12-- yn(0) 00048 * 13-- yn(-ve) 00049 * 14-- lgamma(finite) overflow 00050 * 15-- lgamma(-integer) 00051 * 16-- log(0) 00052 * 17-- log(x<0) 00053 * 18-- log10(0) 00054 * 19-- log10(x<0) 00055 * 20-- pow(0.0,0.0) 00056 * 21-- pow(x,y) overflow 00057 * 22-- pow(x,y) underflow 00058 * 23-- pow(0,negative) 00059 * 24-- pow(neg,non-integral) 00060 * 25-- sinh(finite) overflow 00061 * 26-- sqrt(negative) 00062 * 27-- fmod(x,0) 00063 * 28-- remainder(x,0) 00064 * 29-- acosh(x<1) 00065 * 30-- atanh(|x|>1) 00066 * 31-- atanh(|x|=1) 00067 * 32-- scalb overflow 00068 * 33-- scalb underflow 00069 * 34-- j0(|x|>X_TLOSS) 00070 * 35-- y0(x>X_TLOSS) 00071 * 36-- j1(|x|>X_TLOSS) 00072 * 37-- y1(x>X_TLOSS) 00073 * 38-- jn(|x|>X_TLOSS, n) 00074 * 39-- yn(x>X_TLOSS, n) 00075 * 40-- gamma(finite) overflow 00076 * 41-- gamma(-integer) 00077 * 42-- pow(NaN,0.0) 00078 */ 00079 00080 00081 #ifdef __STDC__ 00082 double __kernel_standard(double x, double y, int type) 00083 #else 00084 double __kernel_standard(x,y,type) 00085 double x,y; int type; 00086 #endif 00087 { 00088 struct exception exc; 00089 #ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ 00090 #define HUGE_VAL inf 00091 double inf = 0.0; 00092 00093 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ 00094 #endif 00095 00096 exc.arg1 = x; 00097 exc.arg2 = y; 00098 switch(type) { 00099 case 1: 00100 case 101: 00101 /* acos(|x|>1) */ 00102 exc.type = DOMAIN; 00103 exc.name = type < 100 ? "acos" : "acosf"; 00104 exc.retval = zero; 00105 if (_LIB_VERSION == _POSIX_) 00106 libm_errno = EDOM; 00107 else if (!matherr(&exc)) { 00108 if(_LIB_VERSION == _SVID_) { 00109 (void) WRITE2("acos: DOMAIN error\n", 19); 00110 } 00111 libm_errno = EDOM; 00112 } 00113 break; 00114 case 2: 00115 case 102: 00116 /* asin(|x|>1) */ 00117 exc.type = DOMAIN; 00118 exc.name = type < 100 ? "asin" : "asinf"; 00119 exc.retval = zero; 00120 if(_LIB_VERSION == _POSIX_) 00121 libm_errno = EDOM; 00122 else if (!matherr(&exc)) { 00123 if(_LIB_VERSION == _SVID_) { 00124 (void) WRITE2("asin: DOMAIN error\n", 19); 00125 } 00126 libm_errno = EDOM; 00127 } 00128 break; 00129 case 3: 00130 case 103: 00131 /* atan2(+-0,+-0) */ 00132 exc.arg1 = y; 00133 exc.arg2 = x; 00134 exc.type = DOMAIN; 00135 exc.name = type < 100 ? "atan2" : "atan2f"; 00136 exc.retval = zero; 00137 if(_LIB_VERSION == _POSIX_) 00138 libm_errno = EDOM; 00139 else if (!matherr(&exc)) { 00140 if(_LIB_VERSION == _SVID_) { 00141 (void) WRITE2("atan2: DOMAIN error\n", 20); 00142 } 00143 libm_errno = EDOM; 00144 } 00145 break; 00146 case 4: 00147 case 104: 00148 /* hypot(finite,finite) overflow */ 00149 exc.type = OVERFLOW; 00150 exc.name = type < 100 ? "hypot" : "hypotf"; 00151 if (_LIB_VERSION == _SVID_) 00152 exc.retval = HUGE; 00153 else 00154 exc.retval = HUGE_VAL; 00155 if (_LIB_VERSION == _POSIX_) 00156 libm_errno = ERANGE; 00157 else if (!matherr(&exc)) { 00158 libm_errno = ERANGE; 00159 } 00160 break; 00161 case 5: 00162 case 105: 00163 /* cosh(finite) overflow */ 00164 exc.type = OVERFLOW; 00165 exc.name = type < 100 ? "cosh" : "coshf"; 00166 if (_LIB_VERSION == _SVID_) 00167 exc.retval = HUGE; 00168 else 00169 exc.retval = HUGE_VAL; 00170 if (_LIB_VERSION == _POSIX_) 00171 libm_errno = ERANGE; 00172 else if (!matherr(&exc)) { 00173 libm_errno = ERANGE; 00174 } 00175 break; 00176 case 6: 00177 case 106: 00178 /* exp(finite) overflow */ 00179 exc.type = OVERFLOW; 00180 exc.name = type < 100 ? "exp" : "expf"; 00181 if (_LIB_VERSION == _SVID_) 00182 exc.retval = HUGE; 00183 else 00184 exc.retval = HUGE_VAL; 00185 if (_LIB_VERSION == _POSIX_) 00186 libm_errno = ERANGE; 00187 else if (!matherr(&exc)) { 00188 libm_errno = ERANGE; 00189 } 00190 break; 00191 case 7: 00192 case 107: 00193 /* exp(finite) underflow */ 00194 exc.type = UNDERFLOW; 00195 exc.name = type < 100 ? "exp" : "expf"; 00196 exc.retval = zero; 00197 if (_LIB_VERSION == _POSIX_) 00198 libm_errno = ERANGE; 00199 else if (!matherr(&exc)) { 00200 libm_errno = ERANGE; 00201 } 00202 break; 00203 case 8: 00204 case 108: 00205 /* y0(0) = -inf */ 00206 exc.type = DOMAIN; /* should be SING for IEEE */ 00207 exc.name = type < 100 ? "y0" : "y0f"; 00208 if (_LIB_VERSION == _SVID_) 00209 exc.retval = -HUGE; 00210 else 00211 exc.retval = -HUGE_VAL; 00212 if (_LIB_VERSION == _POSIX_) 00213 libm_errno = EDOM; 00214 else if (!matherr(&exc)) { 00215 if (_LIB_VERSION == _SVID_) { 00216 (void) WRITE2("y0: DOMAIN error\n", 17); 00217 } 00218 libm_errno = EDOM; 00219 } 00220 break; 00221 case 9: 00222 case 109: 00223 /* y0(x<0) = NaN */ 00224 exc.type = DOMAIN; 00225 exc.name = type < 100 ? "y0" : "y0f"; 00226 if (_LIB_VERSION == _SVID_) 00227 exc.retval = -HUGE; 00228 else 00229 exc.retval = -HUGE_VAL; 00230 if (_LIB_VERSION == _POSIX_) 00231 libm_errno = EDOM; 00232 else if (!matherr(&exc)) { 00233 if (_LIB_VERSION == _SVID_) { 00234 (void) WRITE2("y0: DOMAIN error\n", 17); 00235 } 00236 libm_errno = EDOM; 00237 } 00238 break; 00239 case 10: 00240 case 110: 00241 /* y1(0) = -inf */ 00242 exc.type = DOMAIN; /* should be SING for IEEE */ 00243 exc.name = type < 100 ? "y1" : "y1f"; 00244 if (_LIB_VERSION == _SVID_) 00245 exc.retval = -HUGE; 00246 else 00247 exc.retval = -HUGE_VAL; 00248 if (_LIB_VERSION == _POSIX_) 00249 libm_errno = EDOM; 00250 else if (!matherr(&exc)) { 00251 if (_LIB_VERSION == _SVID_) { 00252 (void) WRITE2("y1: DOMAIN error\n", 17); 00253 } 00254 libm_errno = EDOM; 00255 } 00256 break; 00257 case 11: 00258 case 111: 00259 /* y1(x<0) = NaN */ 00260 exc.type = DOMAIN; 00261 exc.name = type < 100 ? "y1" : "y1f"; 00262 if (_LIB_VERSION == _SVID_) 00263 exc.retval = -HUGE; 00264 else 00265 exc.retval = -HUGE_VAL; 00266 if (_LIB_VERSION == _POSIX_) 00267 libm_errno = EDOM; 00268 else if (!matherr(&exc)) { 00269 if (_LIB_VERSION == _SVID_) { 00270 (void) WRITE2("y1: DOMAIN error\n", 17); 00271 } 00272 libm_errno = EDOM; 00273 } 00274 break; 00275 case 12: 00276 case 112: 00277 /* yn(n,0) = -inf */ 00278 exc.type = DOMAIN; /* should be SING for IEEE */ 00279 exc.name = type < 100 ? "yn" : "ynf"; 00280 if (_LIB_VERSION == _SVID_) 00281 exc.retval = -HUGE; 00282 else 00283 exc.retval = -HUGE_VAL; 00284 if (_LIB_VERSION == _POSIX_) 00285 libm_errno = EDOM; 00286 else if (!matherr(&exc)) { 00287 if (_LIB_VERSION == _SVID_) { 00288 (void) WRITE2("yn: DOMAIN error\n", 17); 00289 } 00290 libm_errno = EDOM; 00291 } 00292 break; 00293 case 13: 00294 case 113: 00295 /* yn(x<0) = NaN */ 00296 exc.type = DOMAIN; 00297 exc.name = type < 100 ? "yn" : "ynf"; 00298 if (_LIB_VERSION == _SVID_) 00299 exc.retval = -HUGE; 00300 else 00301 exc.retval = -HUGE_VAL; 00302 if (_LIB_VERSION == _POSIX_) 00303 libm_errno = EDOM; 00304 else if (!matherr(&exc)) { 00305 if (_LIB_VERSION == _SVID_) { 00306 (void) WRITE2("yn: DOMAIN error\n", 17); 00307 } 00308 libm_errno = EDOM; 00309 } 00310 break; 00311 case 14: 00312 case 114: 00313 /* lgamma(finite) overflow */ 00314 exc.type = OVERFLOW; 00315 exc.name = type < 100 ? "lgamma" : "lgammaf"; 00316 if (_LIB_VERSION == _SVID_) 00317 exc.retval = HUGE; 00318 else 00319 exc.retval = HUGE_VAL; 00320 if (_LIB_VERSION == _POSIX_) 00321 libm_errno = ERANGE; 00322 else if (!matherr(&exc)) { 00323 libm_errno = ERANGE; 00324 } 00325 break; 00326 case 15: 00327 case 115: 00328 /* lgamma(-integer) or lgamma(0) */ 00329 exc.type = SING; 00330 exc.name = type < 100 ? "lgamma" : "lgammaf"; 00331 if (_LIB_VERSION == _SVID_) 00332 exc.retval = HUGE; 00333 else 00334 exc.retval = HUGE_VAL; 00335 if (_LIB_VERSION == _POSIX_) 00336 libm_errno = EDOM; 00337 else if (!matherr(&exc)) { 00338 if (_LIB_VERSION == _SVID_) { 00339 (void) WRITE2("lgamma: SING error\n", 19); 00340 } 00341 libm_errno = EDOM; 00342 } 00343 break; 00344 case 16: 00345 case 116: 00346 /* log(0) */ 00347 exc.type = SING; 00348 exc.name = type < 100 ? "log" : "logf"; 00349 if (_LIB_VERSION == _SVID_) 00350 exc.retval = -HUGE; 00351 else 00352 exc.retval = -HUGE_VAL; 00353 if (_LIB_VERSION == _POSIX_) 00354 libm_errno = ERANGE; 00355 else if (!matherr(&exc)) { 00356 if (_LIB_VERSION == _SVID_) { 00357 (void) WRITE2("log: SING error\n", 16); 00358 } 00359 libm_errno = EDOM; 00360 } 00361 break; 00362 case 17: 00363 case 117: 00364 /* log(x<0) */ 00365 exc.type = DOMAIN; 00366 exc.name = type < 100 ? "log" : "logf"; 00367 if (_LIB_VERSION == _SVID_) 00368 exc.retval = -HUGE; 00369 else 00370 exc.retval = -HUGE_VAL; 00371 if (_LIB_VERSION == _POSIX_) 00372 libm_errno = EDOM; 00373 else if (!matherr(&exc)) { 00374 if (_LIB_VERSION == _SVID_) { 00375 (void) WRITE2("log: DOMAIN error\n", 18); 00376 } 00377 libm_errno = EDOM; 00378 } 00379 break; 00380 case 18: 00381 case 118: 00382 /* log10(0) */ 00383 exc.type = SING; 00384 exc.name = type < 100 ? "log10" : "log10f"; 00385 if (_LIB_VERSION == _SVID_) 00386 exc.retval = -HUGE; 00387 else 00388 exc.retval = -HUGE_VAL; 00389 if (_LIB_VERSION == _POSIX_) 00390 libm_errno = ERANGE; 00391 else if (!matherr(&exc)) { 00392 if (_LIB_VERSION == _SVID_) { 00393 (void) WRITE2("log10: SING error\n", 18); 00394 } 00395 libm_errno = EDOM; 00396 } 00397 break; 00398 case 19: 00399 case 119: 00400 /* log10(x<0) */ 00401 exc.type = DOMAIN; 00402 exc.name = type < 100 ? "log10" : "log10f"; 00403 if (_LIB_VERSION == _SVID_) 00404 exc.retval = -HUGE; 00405 else 00406 exc.retval = -HUGE_VAL; 00407 if (_LIB_VERSION == _POSIX_) 00408 libm_errno = EDOM; 00409 else if (!matherr(&exc)) { 00410 if (_LIB_VERSION == _SVID_) { 00411 (void) WRITE2("log10: DOMAIN error\n", 20); 00412 } 00413 libm_errno = EDOM; 00414 } 00415 break; 00416 case 20: 00417 case 120: 00418 /* pow(0.0,0.0) */ 00419 /* error only if _LIB_VERSION == _SVID_ */ 00420 exc.type = DOMAIN; 00421 exc.name = type < 100 ? "pow" : "powf"; 00422 exc.retval = zero; 00423 if (_LIB_VERSION != _SVID_) exc.retval = 1.0; 00424 else if (!matherr(&exc)) { 00425 (void) WRITE2("pow(0,0): DOMAIN error\n", 23); 00426 libm_errno = EDOM; 00427 } 00428 break; 00429 case 21: 00430 case 121: 00431 /* pow(x,y) overflow */ 00432 exc.type = OVERFLOW; 00433 exc.name = type < 100 ? "pow" : "powf"; 00434 if (_LIB_VERSION == _SVID_) { 00435 exc.retval = HUGE; 00436 y *= 0.5; 00437 if(x<zero&&rint(y)!=y) exc.retval = -HUGE; 00438 } else { 00439 exc.retval = HUGE_VAL; 00440 y *= 0.5; 00441 if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL; 00442 } 00443 if (_LIB_VERSION == _POSIX_) 00444 libm_errno = ERANGE; 00445 else if (!matherr(&exc)) { 00446 libm_errno = ERANGE; 00447 } 00448 break; 00449 case 22: 00450 case 122: 00451 /* pow(x,y) underflow */ 00452 exc.type = UNDERFLOW; 00453 exc.name = type < 100 ? "pow" : "powf"; 00454 exc.retval = zero; 00455 if (_LIB_VERSION == _POSIX_) 00456 libm_errno = ERANGE; 00457 else if (!matherr(&exc)) { 00458 libm_errno = ERANGE; 00459 } 00460 break; 00461 case 23: 00462 case 123: 00463 /* 0**neg */ 00464 exc.type = DOMAIN; 00465 exc.name = type < 100 ? "pow" : "powf"; 00466 if (_LIB_VERSION == _SVID_) 00467 exc.retval = zero; 00468 else 00469 exc.retval = -HUGE_VAL; 00470 if (_LIB_VERSION == _POSIX_) 00471 libm_errno = EDOM; 00472 else if (!matherr(&exc)) { 00473 if (_LIB_VERSION == _SVID_) { 00474 (void) WRITE2("pow(0,neg): DOMAIN error\n", 25); 00475 } 00476 libm_errno = EDOM; 00477 } 00478 break; 00479 case 24: 00480 case 124: 00481 /* neg**non-integral */ 00482 exc.type = DOMAIN; 00483 exc.name = type < 100 ? "pow" : "powf"; 00484 if (_LIB_VERSION == _SVID_) 00485 exc.retval = zero; 00486 else 00487 exc.retval = zero/zero; /* X/Open allow NaN */ 00488 if (_LIB_VERSION == _POSIX_) 00489 libm_errno = EDOM; 00490 else if (!matherr(&exc)) { 00491 if (_LIB_VERSION == _SVID_) { 00492 (void) WRITE2("neg**non-integral: DOMAIN error\n", 32); 00493 } 00494 libm_errno = EDOM; 00495 } 00496 break; 00497 case 25: 00498 case 125: 00499 /* sinh(finite) overflow */ 00500 exc.type = OVERFLOW; 00501 exc.name = type < 100 ? "sinh" : "sinhf"; 00502 if (_LIB_VERSION == _SVID_) 00503 exc.retval = ( (x>zero) ? HUGE : -HUGE); 00504 else 00505 exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); 00506 if (_LIB_VERSION == _POSIX_) 00507 libm_errno = ERANGE; 00508 else if (!matherr(&exc)) { 00509 libm_errno = ERANGE; 00510 } 00511 break; 00512 case 26: 00513 case 126: 00514 /* sqrt(x<0) */ 00515 exc.type = DOMAIN; 00516 exc.name = type < 100 ? "sqrt" : "sqrtf"; 00517 if (_LIB_VERSION == _SVID_) 00518 exc.retval = zero; 00519 else 00520 exc.retval = zero/zero; 00521 if (_LIB_VERSION == _POSIX_) 00522 libm_errno = EDOM; 00523 else if (!matherr(&exc)) { 00524 if (_LIB_VERSION == _SVID_) { 00525 (void) WRITE2("sqrt: DOMAIN error\n", 19); 00526 } 00527 libm_errno = EDOM; 00528 } 00529 break; 00530 case 27: 00531 case 127: 00532 /* fmod(x,0) */ 00533 exc.type = DOMAIN; 00534 exc.name = type < 100 ? "fmod" : "fmodf"; 00535 if (_LIB_VERSION == _SVID_) 00536 exc.retval = x; 00537 else 00538 exc.retval = zero/zero; 00539 if (_LIB_VERSION == _POSIX_) 00540 libm_errno = EDOM; 00541 else if (!matherr(&exc)) { 00542 if (_LIB_VERSION == _SVID_) { 00543 (void) WRITE2("fmod: DOMAIN error\n", 20); 00544 } 00545 libm_errno = EDOM; 00546 } 00547 break; 00548 case 28: 00549 case 128: 00550 /* remainder(x,0) */ 00551 exc.type = DOMAIN; 00552 exc.name = type < 100 ? "remainder" : "remainderf"; 00553 exc.retval = zero/zero; 00554 if (_LIB_VERSION == _POSIX_) 00555 libm_errno = EDOM; 00556 else if (!matherr(&exc)) { 00557 if (_LIB_VERSION == _SVID_) { 00558 (void) WRITE2("remainder: DOMAIN error\n", 24); 00559 } 00560 libm_errno = EDOM; 00561 } 00562 break; 00563 case 29: 00564 case 129: 00565 /* acosh(x<1) */ 00566 exc.type = DOMAIN; 00567 exc.name = type < 100 ? "acosh" : "acoshf"; 00568 exc.retval = zero/zero; 00569 if (_LIB_VERSION == _POSIX_) 00570 libm_errno = EDOM; 00571 else if (!matherr(&exc)) { 00572 if (_LIB_VERSION == _SVID_) { 00573 (void) WRITE2("acosh: DOMAIN error\n", 20); 00574 } 00575 libm_errno = EDOM; 00576 } 00577 break; 00578 case 30: 00579 case 130: 00580 /* atanh(|x|>1) */ 00581 exc.type = DOMAIN; 00582 exc.name = type < 100 ? "atanh" : "atanhf"; 00583 exc.retval = zero/zero; 00584 if (_LIB_VERSION == _POSIX_) 00585 libm_errno = EDOM; 00586 else if (!matherr(&exc)) { 00587 if (_LIB_VERSION == _SVID_) { 00588 (void) WRITE2("atanh: DOMAIN error\n", 20); 00589 } 00590 libm_errno = EDOM; 00591 } 00592 break; 00593 case 31: 00594 case 131: 00595 /* atanh(|x|=1) */ 00596 exc.type = SING; 00597 exc.name = type < 100 ? "atanh" : "atanhf"; 00598 exc.retval = x/zero; /* sign(x)*inf */ 00599 if (_LIB_VERSION == _POSIX_) 00600 libm_errno = EDOM; 00601 else if (!matherr(&exc)) { 00602 if (_LIB_VERSION == _SVID_) { 00603 (void) WRITE2("atanh: SING error\n", 18); 00604 } 00605 libm_errno = EDOM; 00606 } 00607 break; 00608 case 32: 00609 case 132: 00610 /* scalb overflow; SVID also returns +-HUGE_VAL */ 00611 exc.type = OVERFLOW; 00612 exc.name = type < 100 ? "scalb" : "scalbf"; 00613 exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; 00614 if (_LIB_VERSION == _POSIX_) 00615 libm_errno = ERANGE; 00616 else if (!matherr(&exc)) { 00617 libm_errno = ERANGE; 00618 } 00619 break; 00620 case 33: 00621 case 133: 00622 /* scalb underflow */ 00623 exc.type = UNDERFLOW; 00624 exc.name = type < 100 ? "scalb" : "scalbf"; 00625 exc.retval = copysign(zero,x); 00626 if (_LIB_VERSION == _POSIX_) 00627 libm_errno = ERANGE; 00628 else if (!matherr(&exc)) { 00629 libm_errno = ERANGE; 00630 } 00631 break; 00632 case 34: 00633 case 134: 00634 /* j0(|x|>X_TLOSS) */ 00635 exc.type = TLOSS; 00636 exc.name = type < 100 ? "j0" : "j0f"; 00637 exc.retval = zero; 00638 if (_LIB_VERSION == _POSIX_) 00639 libm_errno = ERANGE; 00640 else if (!matherr(&exc)) { 00641 if (_LIB_VERSION == _SVID_) { 00642 (void) WRITE2(exc.name, 2); 00643 (void) WRITE2(": TLOSS error\n", 14); 00644 } 00645 libm_errno = ERANGE; 00646 } 00647 break; 00648 case 35: 00649 case 135: 00650 /* y0(x>X_TLOSS) */ 00651 exc.type = TLOSS; 00652 exc.name = type < 100 ? "y0" : "y0f"; 00653 exc.retval = zero; 00654 if (_LIB_VERSION == _POSIX_) 00655 libm_errno = ERANGE; 00656 else if (!matherr(&exc)) { 00657 if (_LIB_VERSION == _SVID_) { 00658 (void) WRITE2(exc.name, 2); 00659 (void) WRITE2(": TLOSS error\n", 14); 00660 } 00661 libm_errno = ERANGE; 00662 } 00663 break; 00664 case 36: 00665 case 136: 00666 /* j1(|x|>X_TLOSS) */ 00667 exc.type = TLOSS; 00668 exc.name = type < 100 ? "j1" : "j1f"; 00669 exc.retval = zero; 00670 if (_LIB_VERSION == _POSIX_) 00671 libm_errno = ERANGE; 00672 else if (!matherr(&exc)) { 00673 if (_LIB_VERSION == _SVID_) { 00674 (void) WRITE2(exc.name, 2); 00675 (void) WRITE2(": TLOSS error\n", 14); 00676 } 00677 libm_errno = ERANGE; 00678 } 00679 break; 00680 case 37: 00681 case 137: 00682 /* y1(x>X_TLOSS) */ 00683 exc.type = TLOSS; 00684 exc.name = type < 100 ? "y1" : "y1f"; 00685 exc.retval = zero; 00686 if (_LIB_VERSION == _POSIX_) 00687 libm_errno = ERANGE; 00688 else if (!matherr(&exc)) { 00689 if (_LIB_VERSION == _SVID_) { 00690 (void) WRITE2(exc.name, 2); 00691 (void) WRITE2(": TLOSS error\n", 14); 00692 } 00693 libm_errno = ERANGE; 00694 } 00695 break; 00696 case 38: 00697 case 138: 00698 /* jn(|x|>X_TLOSS) */ 00699 exc.type = TLOSS; 00700 exc.name = type < 100 ? "jn" : "jnf"; 00701 exc.retval = zero; 00702 if (_LIB_VERSION == _POSIX_) 00703 libm_errno = ERANGE; 00704 else if (!matherr(&exc)) { 00705 if (_LIB_VERSION == _SVID_) { 00706 (void) WRITE2(exc.name, 2); 00707 (void) WRITE2(": TLOSS error\n", 14); 00708 } 00709 libm_errno = ERANGE; 00710 } 00711 break; 00712 case 39: 00713 case 139: 00714 /* yn(x>X_TLOSS) */ 00715 exc.type = TLOSS; 00716 exc.name = type < 100 ? "yn" : "ynf"; 00717 exc.retval = zero; 00718 if (_LIB_VERSION == _POSIX_) 00719 libm_errno = ERANGE; 00720 else if (!matherr(&exc)) { 00721 if (_LIB_VERSION == _SVID_) { 00722 (void) WRITE2(exc.name, 2); 00723 (void) WRITE2(": TLOSS error\n", 14); 00724 } 00725 libm_errno = ERANGE; 00726 } 00727 break; 00728 case 40: 00729 case 140: 00730 /* gamma(finite) overflow */ 00731 exc.type = OVERFLOW; 00732 exc.name = type < 100 ? "gamma" : "gammaf"; 00733 if (_LIB_VERSION == _SVID_) 00734 exc.retval = HUGE; 00735 else 00736 exc.retval = HUGE_VAL; 00737 if (_LIB_VERSION == _POSIX_) 00738 libm_errno = ERANGE; 00739 else if (!matherr(&exc)) { 00740 libm_errno = ERANGE; 00741 } 00742 break; 00743 case 41: 00744 case 141: 00745 /* gamma(-integer) or gamma(0) */ 00746 exc.type = SING; 00747 exc.name = type < 100 ? "gamma" : "gammaf"; 00748 if (_LIB_VERSION == _SVID_) 00749 exc.retval = HUGE; 00750 else 00751 exc.retval = HUGE_VAL; 00752 if (_LIB_VERSION == _POSIX_) 00753 libm_errno = EDOM; 00754 else if (!matherr(&exc)) { 00755 if (_LIB_VERSION == _SVID_) { 00756 (void) WRITE2("gamma: SING error\n", 18); 00757 } 00758 libm_errno = EDOM; 00759 } 00760 break; 00761 case 42: 00762 case 142: 00763 /* pow(NaN,0.0) */ 00764 /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ 00765 exc.type = DOMAIN; 00766 exc.name = type < 100 ? "pow" : "powf"; 00767 exc.retval = x; 00768 if (_LIB_VERSION == _IEEE_ || 00769 _LIB_VERSION == _POSIX_) exc.retval = 1.0; 00770 else if (!matherr(&exc)) { 00771 libm_errno = EDOM; 00772 } 00773 break; 00774 } 00775 return exc.retval; 00776 }

Generated on Thu Nov 20 11:49:51 2008 for RTAI API by doxygen 1.3.8