Back to index

glibc  2.9
w_powf.c
Go to the documentation of this file.
00001 /* w_powf.c -- float version of w_pow.c.
00002  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
00003  */
00004 
00005 /*
00006  * ====================================================
00007  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00008  *
00009  * Developed at SunPro, a Sun Microsystems, Inc. business.
00010  * Permission to use, copy, modify, and distribute this
00011  * software is freely granted, provided that this notice
00012  * is preserved.
00013  * ====================================================
00014  */
00015 
00016 #if defined(LIBM_SCCS) && !defined(lint)
00017 static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $";
00018 #endif
00019 
00020 /*
00021  * wrapper powf(x,y) return x**y
00022  */
00023 
00024 #include <math.h>
00025 #include "math_private.h"
00026 
00027 
00028 #ifdef __STDC__
00029        float __powf(float x, float y)     /* wrapper powf */
00030 #else
00031        float __powf(x,y)                  /* wrapper powf */
00032        float x,y;
00033 #endif
00034 {
00035 #ifdef _IEEE_LIBM
00036        return  __ieee754_powf(x,y);
00037 #else
00038        float z;
00039        z=__ieee754_powf(x,y);
00040        if(_LIB_VERSION == _IEEE_|| __isnanf(y)) return z;
00041        if(__isnanf(x)) {
00042            if(y==(float)0.0)
00043                /* powf(NaN,0.0) */
00044                return (float)__kernel_standard((double)x,(double)y,142);
00045            else
00046               return z;
00047        }
00048        if(x==(float)0.0) {
00049            if(y==(float)0.0)
00050                /* powf(0.0,0.0) */
00051                return (float)__kernel_standard((double)x,(double)y,120);
00052            if(__finitef(y)&&y<(float)0.0) {
00053              if (signbit (x) && signbit (z))
00054                /* powf(0.0,negative) */
00055                return (float)__kernel_standard((double)x,(double)y,123);
00056              else
00057                return (float)__kernel_standard((double)x,(double)y,143);
00058            }
00059            return z;
00060        }
00061        if(!__finitef(z)) {
00062            if(__finitef(x)&&__finitef(y)) {
00063                if(__isnanf(z))
00064                   /* powf neg**non-int */
00065                    return (float)__kernel_standard((double)x,(double)y,124);
00066                else
00067                   /* powf overflow */
00068                    return (float)__kernel_standard((double)x,(double)y,121);
00069            }
00070        }
00071        if(z==(float)0.0&&__finitef(x)&&__finitef(y))
00072            /* powf underflow */
00073            return (float)__kernel_standard((double)x,(double)y,122);
00074        return z;
00075 #endif
00076 }
00077 weak_alias (__powf, powf)