xref: /netbsd-src/lib/libm/src/w_pow.c (revision 1ca5c1b28139779176bd5c13ad7c5f25c0bcd5f8)
1 
2 
3 /* @(#)w_pow.c 5.2 93/10/01 */
4 /*
5  * ====================================================
6  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7  *
8  * Developed at SunPro, a Sun Microsystems, Inc. business.
9  * Permission to use, copy, modify, and distribute this
10  * software is freely granted, provided that this notice
11  * is preserved.
12  * ====================================================
13  */
14 
15 #include <sys/cdefs.h>
16 #if defined(LIBM_SCCS) && !defined(lint)
17 __RCSID("$NetBSD: w_pow.c,v 1.6 1999/07/02 15:37:45 simonb Exp $");
18 #endif
19 
20 /*
21  * wrapper pow(x,y) return x**y
22  */
23 
24 #include "math.h"
25 #include "math_private.h"
26 
27 
28 #ifdef __STDC__
29 	double pow(double x, double y)	/* wrapper pow */
30 #else
31 	double pow(x,y)			/* wrapper pow */
32 	double x,y;
33 #endif
34 {
35 #ifdef _IEEE_LIBM
36 	return  __ieee754_pow(x,y);
37 #else
38 	double z;
39 	z=__ieee754_pow(x,y);
40 	if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
41 	if(isnan(x)) {
42 	    if(y==0.0)
43 	        return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
44 	    else
45 		return z;
46 	}
47 	if(x==0.0){
48 	    if(y==0.0)
49 	        return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
50 	    if(finite(y)&&y<0.0)
51 	        return __kernel_standard(x,y,23); /* pow(0.0,negative) */
52 	    return z;
53 	}
54 	if(!finite(z)) {
55 	    if(finite(x)&&finite(y)) {
56 	        if(isnan(z))
57 	            return __kernel_standard(x,y,24); /* pow neg**non-int */
58 	        else
59 	            return __kernel_standard(x,y,21); /* pow overflow */
60 	    }
61 	}
62 	if(z==0.0&&finite(x)&&finite(y))
63 	    return __kernel_standard(x,y,22); /* pow underflow */
64 	return z;
65 #endif
66 }
67