POK
sqrt.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 13:44:27 2009
15  */
16 
17 /*
18  * ====================================================
19  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
20  *
21  * Developed at SunPro, a Sun Microsystems, Inc. business.
22  * Permission to use, copy, modify, and distribute this
23  * software is freely granted, provided that this notice
24  * is preserved.
25  * ====================================================
26  */
27 
28 /*
29  * wrapper sqrt(x)
30  */
31 
32 #ifdef POK_NEEDS_LIBMATH
33 
34 #include "math_private.h"
35 #include <libm.h>
36 
37 double sqrt (double x) /* wrapper sqrt */
38 {
39 #ifdef _IEEE_LIBM
40  return __ieee754_sqrt(x);
41 #else
42  double z;
43  z = __ieee754_sqrt(x);
44  if(isnan(x)) return z;
45  if(x<0.0) {
46  return -1.0;
47  } else
48  return z;
49 #endif
50 }
51 
52 #endif
53