mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-13 04:42:13 -08:00
Increased precision of PI
This commit is contained in:
parent
ad286a7901
commit
ebefa6ed13
3 changed files with 18 additions and 29 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,22 +16,13 @@
|
|||
*/
|
||||
|
||||
#include <ecl/ecl.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#ifdef _MSC_VER
|
||||
# undef complex
|
||||
#endif
|
||||
#include <float.h>
|
||||
#include <ecl/internal.h>
|
||||
|
||||
#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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue