diff --git a/src/c/num_sfun.d b/src/c/num_sfun.d index ca562e8b1..1cfc93c04 100644 --- a/src/c/num_sfun.d +++ b/src/c/num_sfun.d @@ -21,13 +21,6 @@ # undef complex #endif #include "ecl/internal.h" -#ifndef M_PI -# ifdef PI -# define M_PI PI -# else -# define M_PI 3.14159265358979323846 -# endif -#endif #ifndef HAVE_LOG1P double @@ -414,19 +407,19 @@ ecl_atan2_double(double y, double x) } } else if (x == 0) { if (y > 0) { - return M_PI / 2.0; + return ECL_PI2_D; } else if (y == 0) { FEerror("Logarithmic singularity.", 0); } else { - return -M_PI / 2.0; + return -ECL_PI2_D; } } else { if (y > 0) { - return M_PI - atan(y / -x); + return ECL_PI_D - atan(y / -x); } else if (y == 0) { - return M_PI; + return ECL_PI_D; } else { - return -M_PI + atan(-y / -x); + return -ECL_PI_D + atan(-y / -x); } } } @@ -445,19 +438,19 @@ ecl_atan2_long_double(long double y, long double x) } } else if (x == 0) { if (y > 0) { - return M_PI / 2.0; + return ECL_PI2_L; } else if (y == 0) { FEerror("Logarithmic singularity.", 0); } else { - return -M_PI / 2.0; + return -ECL_PI2_L; } } else { if (y > 0) { - return M_PI - atanl(y / -x); + return ECL_PI_L - atanl(y / -x); } else if (y == 0) { - return M_PI; + return ECL_PI_L; } else { - return -M_PI + atanl(-y / -x); + return -ECL_PI_L + atanl(-y / -x); } } } diff --git a/src/c/number.d b/src/c/number.d index 087a116aa..558fa0e5a 100644 --- a/src/c/number.d +++ b/src/c/number.d @@ -16,22 +16,13 @@ */ #include -#include #include +#include #ifdef _MSC_VER # undef complex #endif -#include #include -#ifndef M_PI -# ifdef PI -# define M_PI PI -# else -# define M_PI 3.14159265358979323846 -# endif -#endif - cl_fixnum fixint(cl_object x) { @@ -604,9 +595,9 @@ init_number(void) ecl_make_complex(ecl_make_singlefloat(0.0), ecl_make_singlefloat(2.0)); #ifdef ECL_LONG_FLOAT - ECL_SET(@'pi', make_longfloat(M_PI)); + ECL_SET(@'pi', make_longfloat((long double)ECL_PI_L)); #else - ECL_SET(@'pi', ecl_make_doublefloat(M_PI)); + ECL_SET(@'pi', ecl_make_doublefloat((double)ECL_PI_D)); #endif init_big(); diff --git a/src/h/internal.h b/src/h/internal.h index d81cd09ae..ad1cfe034 100644 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -216,6 +216,11 @@ typedef int fenv_t; # define fesetenv(bits) _controlfp(*(bits), MCW_EM) #endif +#define ECL_PI_D 3.14159265358979323846264338327950288 +#define ECL_PI_L 3.14159265358979323846264338327950288l +#define ECL_PI2_D 1.57079632679489661923132169163975144 +#define ECL_PI2_L 1.57079632679489661923132169163975144l + /* * Fake several ISO C99 mathematical functions */