Back to index

glibc  2.9
w_pow.c
Go to the documentation of this file.
00001 
00002 
00003 /* @(#)w_pow.c 5.2 93/10/01 */
00004 /*
00005  * ====================================================
00006  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00007  *
00008  * Developed at SunPro, a Sun Microsystems, Inc. business.
00009  * Permission to use, copy, modify, and distribute this
00010  * software is freely granted, provided that this notice
00011  * is preserved.
00012  * ====================================================
00013  */
00014 
00015 /*
00016  * wrapper pow(x,y) return x**y
00017  */
00018 
00019 #include <math.h>
00020 #include "math_private.h"
00021 
00022 
00023 #ifdef __STDC__
00024        double __pow(double x, double y)   /* wrapper pow */
00025 #else
00026        double __pow(x,y)                  /* wrapper pow */
00027        double x,y;
00028 #endif
00029 {
00030 #ifdef _IEEE_LIBM
00031        return  __ieee754_pow(x,y);
00032 #else
00033        double z;
00034        z=__ieee754_pow(x,y);
00035        if(_LIB_VERSION == _IEEE_|| __isnan(y)) return z;
00036        if(__isnan(x)) {
00037            if(y==0.0)
00038                return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
00039            else
00040               return z;
00041        }
00042        if(x==0.0) {
00043            if(y==0.0)
00044                return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
00045            if(__finite(y)&&y<0.0) {
00046              if (signbit (x) && signbit (z))
00047                return __kernel_standard(x,y,23); /* pow(-0.0,negative) */
00048              else
00049                return __kernel_standard(x,y,43); /* pow(+0.0,negative) */
00050            }
00051            return z;
00052        }
00053        if(!__finite(z)) {
00054            if(__finite(x)&&__finite(y)) {
00055                if(__isnan(z))
00056                    return __kernel_standard(x,y,24); /* pow neg**non-int */
00057                else
00058                    return __kernel_standard(x,y,21); /* pow overflow */
00059            }
00060        }
00061        if(z==0.0&&__finite(x)&&__finite(y))
00062            return __kernel_standard(x,y,22); /* pow underflow */
00063        return z;
00064 #endif
00065 }
00066 weak_alias (__pow, pow)
00067 #ifdef NO_LONG_DOUBLE
00068 strong_alias (__pow, __powl)
00069 weak_alias (__pow, powl)
00070 #endif