Back to index

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