POK
pow.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Fri Jan 30 14:41:34 2009
15  */
16 
17 
18 
19 /* @(#)w_pow.c 5.2 93/10/01 */
20 /*
21  * ====================================================
22  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
23  *
24  * Developed at SunPro, a Sun Microsystems, Inc. business.
25  * Permission to use, copy, modify, and distribute this
26  * software is freely granted, provided that this notice
27  * is preserved.
28  * ====================================================
29  */
30 
31 #ifdef POK_NEEDS_LIBMATH
32 
33 /*
34  * wrapper pow(x,y) return x**y
35  */
36 
37 #include <libm.h>
38 #include "math_private.h"
39 
40 
41 double
42 pow(double x, double y) /* wrapper pow */
43 {
44 #ifdef _IEEE_LIBM
45  return __ieee754_pow(x,y);
46 #else
47  double z;
48  z=__ieee754_pow(x,y);
49  if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
50  if(isnan(x)) {
51  if(y==0.0)
52  return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
53  else
54  return z;
55  }
56  if(x==0.0){
57  if(y==0.0)
58  return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
59  if(finite(y)&&y<0.0)
60  return __kernel_standard(x,y,23); /* pow(0.0,negative) */
61  return z;
62  }
63  if(!finite(z)) {
64  if(finite(x)&&finite(y)) {
65  if(isnan(z))
66  return __kernel_standard(x,y,24); /* pow neg**non-int */
67  else
68  return __kernel_standard(x,y,21); /* pow overflow */
69  }
70  }
71  if(z==0.0&&finite(x)&&finite(y))
72  return __kernel_standard(x,y,22); /* pow underflow */
73  return z;
74 #endif
75 }
76 
77 #endif