1 |
|
2 |
|
3 /* |
|
4 * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. |
|
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
6 * |
|
7 * This code is free software; you can redistribute it and/or modify it |
|
8 * under the terms of the GNU General Public License version 2 only, as |
|
9 * published by the Free Software Foundation. Oracle designates this |
|
10 * particular file as subject to the "Classpath" exception as provided |
|
11 * by Oracle in the LICENSE file that accompanied this code. |
|
12 * |
|
13 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 * version 2 for more details (a copy is included in the LICENSE file that |
|
17 * accompanied this code). |
|
18 * |
|
19 * You should have received a copy of the GNU General Public License version |
|
20 * 2 along with this work; if not, write to the Free Software Foundation, |
|
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
22 * |
|
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
24 * or visit www.oracle.com if you need additional information or have any |
|
25 * questions. |
|
26 */ |
|
27 |
|
28 /* |
|
29 * wrapper pow(x,y) return x**y |
|
30 */ |
|
31 |
|
32 #include "fdlibm.h" |
|
33 |
|
34 |
|
35 #ifdef __STDC__ |
|
36 double pow(double x, double y) /* wrapper pow */ |
|
37 #else |
|
38 double pow(x,y) /* wrapper pow */ |
|
39 double x,y; |
|
40 #endif |
|
41 { |
|
42 #ifdef _IEEE_LIBM |
|
43 return __ieee754_pow(x,y); |
|
44 #else |
|
45 double z; |
|
46 z=__ieee754_pow(x,y); |
|
47 if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; |
|
48 if(isnan(x)) { |
|
49 if(y==0.0) |
|
50 return __kernel_standard(x,y,42); /* pow(NaN,0.0) */ |
|
51 else |
|
52 return z; |
|
53 } |
|
54 if(x==0.0){ |
|
55 if(y==0.0) |
|
56 return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ |
|
57 if(finite(y)&&y<0.0) |
|
58 return __kernel_standard(x,y,23); /* pow(0.0,negative) */ |
|
59 return z; |
|
60 } |
|
61 if(!finite(z)) { |
|
62 if(finite(x)&&finite(y)) { |
|
63 if(isnan(z)) |
|
64 return __kernel_standard(x,y,24); /* pow neg**non-int */ |
|
65 else |
|
66 return __kernel_standard(x,y,21); /* pow overflow */ |
|
67 } |
|
68 } |
|
69 if(z==0.0&&finite(x)&&finite(y)) |
|
70 return __kernel_standard(x,y,22); /* pow underflow */ |
|
71 return z; |
|
72 #endif |
|
73 } |
|