Ejemplo n.º 1
0
        double asin(double x)           /* wrapper asin */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_asin(x);
#else
        double z;
        z = __ieee754_asin(x);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnan(x)) return z;
        if(fabs(x)>1.0) {
                return __kernel_standard(x,x,2); /* asin(|x|>1) */
        } else
            return z;
#endif
}
Ejemplo n.º 2
0
        double sinh(double x)           /* wrapper sinh */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_sinh(x);
#else
        double z; 
        z = __ieee754_sinh(x);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z;
        if(!finite(z)&&finite(x)) {
            return __kernel_standard(x,x,25); /* sinh overflow */
        } else
            return z;
#endif
}
Ejemplo n.º 3
0
        double fmod(double x, double y) /* wrapper fmod */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_fmod(x,y);
#else
        double z;
        z = __ieee754_fmod(x,y);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE ||isnan(y)||isnan(x)) return z;
        if(y==0.0) {
                return __kernel_standard(x,y,27); /* fmod(x,0) */
        } else
            return z;
#endif
}
Ejemplo n.º 4
0
        double cosh(double x)           /* wrapper cosh */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_cosh(x);
#else
        double z;
        z = __ieee754_cosh(x);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnan(x)) return z;
        if(fabs(x)>7.10475860073943863426e+02) {        
                return __kernel_standard(x,x,5); /* cosh overflow */
        } else
            return z;
#endif
}
Ejemplo n.º 5
0
        double atan2(double y, double x)        /* wrapper atan2 */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_atan2(y,x);
#else
        double z;
        z = __ieee754_atan2(y,x);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE||isnan(x)||isnan(y)) return z;
        if(x==0.0&&y==0.0) {
                return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */
        } else
            return z;
#endif
}
Ejemplo n.º 6
0
        double log(double x)            /* wrapper log */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_log(x);
#else
        double z;
        z = __ieee754_log(x);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnan(x) || x > 0.0) return z;
        if(x==0.0)
            return __kernel_standard(x,x,16); /* log(0) */
        else 
            return __kernel_standard(x,x,17); /* log(x<0) */
#endif
}
Ejemplo n.º 7
0
        double remainder(double x, double y)    /* wrapper remainder */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_remainder(x,y);
#else
        double z;
        z = __ieee754_remainder(x,y);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE || isnan(y)) return z;
        if(y==0.0) 
            return __kernel_standard(x,y,28); /* remainder(x,0) */
        else
            return z;
#endif
}
Ejemplo n.º 8
0
double
ldexp(double x, int exp)
{
    double z;
    
    z = scalbn(x,exp);
    
#ifndef CYGSEM_LIBM_COMPAT_IEEE_ONLY
    if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z;
    if(!(finite(z)||isnan(z))&&finite(x)) {
        return __kernel_standard(x,(double)exp,43); /* ldexp overflow */
    }
    if(z==0.0&&z!=x) {
        return __kernel_standard(x,(double)exp,44); /* ldexp underflow */
    } 
#endif

    return z;
}
Ejemplo n.º 9
0
        double scalb(double x, int fn)          /* wrapper scalb */
#endif
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return __ieee754_scalb(x,fn);
#else
        double z;
        z = __ieee754_scalb(x,fn);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z;
        if(!(finite(z)||isnan(z))&&finite(x)) {
            return __kernel_standard(x,(double)fn,32); /* scalb overflow */
        }
        if(z==0.0&&z!=x) {
            return __kernel_standard(x,(double)fn,33); /* scalb underflow */
        } 
#ifdef CYGFUN_LIBM_SVID3_scalb
        if(!finite(fn)) errno = ERANGE;
#endif
        return z;
#endif 
}
Ejemplo n.º 10
0
        double pow(double x, double y)  /* wrapper pow */
{
#ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY
        return  __ieee754_pow(x,y);
#else
        double z;
        z=__ieee754_pow(x,y);
        if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE||
           isnan(y))
            return z;
        if(isnan(x)) {
            if(y==0.0) 
                return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
            else 
                return z;
        }
        if(x==0.0){ 
            if(y==0.0)
                return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
            if(finite(y)&&y<0.0)
                return __kernel_standard(x,y,23); /* pow(0.0,negative) */
            return z;
        }
        if(!finite(z)) {
            if(finite(x)&&finite(y)) {
                if(isnan(z))
                    return __kernel_standard(x,y,24);/* pow neg**non-int */
                else 
                    return __kernel_standard(x,y,21); /* pow overflow */
            }
        } 
        if(z==0.0&&finite(x)&&finite(y))
            return __kernel_standard(x,y,22); /* pow underflow */
        return z;
#endif
}
Ejemplo n.º 11
0
double
__kernel_standard(double x, double y, int type) 
{
        struct exception exc;

#ifdef CYGSEM_LIBM_USE_STDERR
        (void) fflush(stdout);
#endif
        exc.arg1 = x;
        exc.arg2 = y;
        switch(type) {
            case 1:
                /* acos(|x|>1) */
                exc.type = DOMAIN;
                exc.name = "acos";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                    (void) WRITE2("acos: DOMAIN error\n", 19);
                  }
                  errno = EDOM;
                }
                break;
            case 2:
                /* asin(|x|>1) */
                exc.type = DOMAIN;
                exc.name = "asin";
                exc.retval = zero;
                if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("asin: DOMAIN error\n", 19);
                  }
                  errno = EDOM;
                }
                break;
            case 3:
                /* atan2(+-0,+-0) */
                exc.arg1 = y;
                exc.arg2 = x;
                exc.type = DOMAIN;
                exc.name = "atan2";
                exc.retval = zero;
                if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("atan2: DOMAIN error\n", 20);
                      }
                  errno = EDOM;
                }
                break;
            case 4:
                /* hypot(finite,finite) overflow */
                exc.type = OVERFLOW;
                exc.name = "hypot";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 5:
                /* cosh(finite) overflow */
                exc.type = OVERFLOW;
                exc.name = "cosh";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 6:
                /* exp(finite) overflow */
                exc.type = OVERFLOW;
                exc.name = "exp";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 7:
                /* exp(finite) underflow */
                exc.type = UNDERFLOW;
                exc.name = "exp";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 8:
                /* y0(0) = -inf */
                exc.type = DOMAIN;      /* should be SING for IEEE */
                exc.name = "y0";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("y0: DOMAIN error\n", 17);
                      }
                  errno = EDOM;
                }
                break;
            case 9:
                /* y0(x<0) = NaN */
                exc.type = DOMAIN;
                exc.name = "y0";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("y0: DOMAIN error\n", 17);
                      }
                  errno = EDOM;
                }
                break;
            case 10:
                /* y1(0) = -inf */
                exc.type = DOMAIN;      /* should be SING for IEEE */
                exc.name = "y1";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("y1: DOMAIN error\n", 17);
                      }
                  errno = EDOM;
                }
                break;
            case 11:
                /* y1(x<0) = NaN */
                exc.type = DOMAIN;
                exc.name = "y1";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("y1: DOMAIN error\n", 17);
                      }
                  errno = EDOM;
                }
                break;
            case 12:
                /* yn(n,0) = -inf */
                exc.type = DOMAIN;      /* should be SING for IEEE */
                exc.name = "yn";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("yn: DOMAIN error\n", 17);
                      }
                  errno = EDOM;
                }
                break;
            case 13:
                /* yn(x<0) = NaN */
                exc.type = DOMAIN;
                exc.name = "yn";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("yn: DOMAIN error\n", 17);
                      }
                  errno = EDOM;
                }
                break;
            case 14:
                /* lgamma(finite) overflow */
                exc.type = OVERFLOW;
                exc.name = "lgamma";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 15:
                /* lgamma(-integer) or lgamma(0) */
                exc.type = SING;
                exc.name = "lgamma";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("lgamma: SING error\n", 19);
                      }
                  errno = EDOM;
                }
                break;
            case 16:
                /* log(0) */
                exc.type = SING;
                exc.name = "log";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("log: SING error\n", 16);
                      }
                  errno = EDOM;
                }
                break;
            case 17:
                /* log(x<0) */
                exc.type = DOMAIN;
                exc.name = "log";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("log: DOMAIN error\n", 18);
                      }
                  errno = EDOM;
                }
                break;
            case 18:
                /* log10(0) */
                exc.type = SING;
                exc.name = "log10";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("log10: SING error\n", 18);
                      }
                  errno = EDOM;
                }
                break;
            case 19:
                /* log10(x<0) */
                exc.type = DOMAIN;
                exc.name = "log10";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = -HUGE;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("log10: DOMAIN error\n", 20);
                      }
                  errno = EDOM;
                }
                break;
            case 20:
                /* pow(0.0,0.0) */
                /* error only if cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID */
                exc.type = DOMAIN;
                exc.name = "pow";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() != CYGNUM_LIBM_COMPAT_SVID) exc.retval = 1.0;
                else if (!matherr(&exc)) {
                        (void) WRITE2("pow(0,0): DOMAIN error\n", 23);
                        errno = EDOM;
                }
                break;
            case 21:
                /* pow(x,y) overflow */
                exc.type = OVERFLOW;
                exc.name = "pow";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                  exc.retval = HUGE;
                  y *= 0.5;
                  if(x<zero&&rint(y)!=y) exc.retval = -HUGE;
                } else {
                  exc.retval = HUGE_VAL;
                  y *= 0.5;
                  if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL;
                }
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 22:
                /* pow(x,y) underflow */
                exc.type = UNDERFLOW;
                exc.name = "pow";
                exc.retval =  zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 23:
                /* 0**neg */
                exc.type = DOMAIN;
                exc.name = "pow";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) 
                  exc.retval = zero;
                else
                  exc.retval = -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
                      }
                  errno = EDOM;
                }
                break;
            case 24:
                /* neg**non-integral */
                exc.type = DOMAIN;
                exc.name = "pow";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) 
                    exc.retval = zero;
                else 
                    exc.retval = zero/zero;     /* X/Open allow NaN */
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) 
                   errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("neg**non-integral: DOMAIN error\n", 32);
                      }
                  errno = EDOM;
                }
                break;
            case 25:
                /* sinh(finite) overflow */
                exc.type = OVERFLOW;
                exc.name = "sinh";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = ( (x>zero) ? HUGE : -HUGE);
                else
                  exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL);
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 26:
                /* sqrt(x<0) */
                exc.type = DOMAIN;
                exc.name = "sqrt";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = zero;
                else
                  exc.retval = zero/zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("sqrt: DOMAIN error\n", 19);
                      }
                  errno = EDOM;
                }
                break;
            case 27:
                /* fmod(x,0) */
                exc.type = DOMAIN;
                exc.name = "fmod";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                    exc.retval = x;
                else
                    exc.retval = zero/zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                    (void) WRITE2("fmod:  DOMAIN error\n", 20);
                  }
                  errno = EDOM;
                }
                break;
            case 28:
                /* remainder(x,0) */
                exc.type = DOMAIN;
                exc.name = "remainder";
                exc.retval = zero/zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                    (void) WRITE2("remainder: DOMAIN error\n", 24);
                  }
                  errno = EDOM;
                }
                break;
            case 29:
                /* acosh(x<1) */
                exc.type = DOMAIN;
                exc.name = "acosh";
                exc.retval = zero/zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                    (void) WRITE2("acosh: DOMAIN error\n", 20);
                  }
                  errno = EDOM;
                }
                break;
            case 30:
                /* atanh(|x|>1) */
                exc.type = DOMAIN;
                exc.name = "atanh";
                exc.retval = zero/zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                    (void) WRITE2("atanh: DOMAIN error\n", 20);
                  }
                  errno = EDOM;
                }
                break;
            case 31:
                /* atanh(|x|=1) */
                exc.type = SING;
                exc.name = "atanh";
                exc.retval = x/zero;    /* sign(x)*inf */
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                    (void) WRITE2("atanh: SING error\n", 18);
                  }
                  errno = EDOM;
                }
                break;
            case 32:
                /* scalb overflow; SVID also returns +-HUGE_VAL */
                exc.type = OVERFLOW;
                exc.name = "scalb";
                exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 33:
                /* scalb underflow */
                exc.type = UNDERFLOW;
                exc.name = "scalb";
                exc.retval = copysign(zero,x);
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 34:
                /* j0(|x|>X_TLOSS) */
                exc.type = TLOSS;
                exc.name = "j0";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                                (void) WRITE2(exc.name, 2);
                                (void) WRITE2(": TLOSS error\n", 14);
                        }
                        errno = ERANGE;
                }        
                break;
            case 35:
                /* y0(x>X_TLOSS) */
                exc.type = TLOSS;
                exc.name = "y0";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                                (void) WRITE2(exc.name, 2);
                                (void) WRITE2(": TLOSS error\n", 14);
                        }
                        errno = ERANGE;
                }        
                break;
            case 36:
                /* j1(|x|>X_TLOSS) */
                exc.type = TLOSS;
                exc.name = "j1";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                                (void) WRITE2(exc.name, 2);
                                (void) WRITE2(": TLOSS error\n", 14);
                        }
                        errno = ERANGE;
                }        
                break;
            case 37:
                /* y1(x>X_TLOSS) */
                exc.type = TLOSS;
                exc.name = "y1";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                                (void) WRITE2(exc.name, 2);
                                (void) WRITE2(": TLOSS error\n", 14);
                        }
                        errno = ERANGE;
                }        
                break;
            case 38:
                /* jn(|x|>X_TLOSS) */
                exc.type = TLOSS;
                exc.name = "jn";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                                (void) WRITE2(exc.name, 2);
                                (void) WRITE2(": TLOSS error\n", 14);
                        }
                        errno = ERANGE;
                }        
                break;
            case 39:
                /* yn(x>X_TLOSS) */
                exc.type = TLOSS;
                exc.name = "yn";
                exc.retval = zero;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                        errno = ERANGE;
                else if (!matherr(&exc)) {
                        if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                                (void) WRITE2(exc.name, 2);
                                (void) WRITE2(": TLOSS error\n", 14);
                        }
                        errno = ERANGE;
                }        
                break;
            case 40:
                /* gamma(finite) overflow */
                exc.type = OVERFLOW;
                exc.name = "gamma";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                  errno = ERANGE;
                }
                break;
            case 41:
                /* gamma(-integer) or gamma(0) */
                exc.type = SING;
                exc.name = "gamma";
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID)
                  exc.retval = HUGE;
                else
                  exc.retval = HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = EDOM;
                else if (!matherr(&exc)) {
                  if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID) {
                        (void) WRITE2("gamma: SING error\n", 18);
                      }
                  errno = EDOM;
                }
                break;
            case 42:
                /* pow(NaN,0.0) */
                /* error only if cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_SVID & CYGNUM_LIBM_COMPAT_XOPEN */
                exc.type = DOMAIN;
                exc.name = "pow";
                exc.retval = x;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE ||
                    cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX) exc.retval = 1.0;
                else if (!matherr(&exc)) {
                        errno = EDOM;
                }
                break;
            case 43:
                /* ldexp overflow; SVID also returns +-HUGE_VAL */
                exc.type = OVERFLOW;
                exc.name = "ldexp";
                exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
            case 44:
                /* ldexp underflow */
                exc.type = UNDERFLOW;
                exc.name = "ldexp";
                exc.retval = copysign(zero,x);
                if (cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_POSIX)
                  errno = ERANGE;
                else if (!matherr(&exc)) {
                        errno = ERANGE;
                }
                break;
        }
        return exc.retval; 
}