use correct type for PI (double).

promote defines to platform-header.
This commit is contained in:
Enno Rehling 2017-05-06 09:44:06 +02:00
parent 7ad5c4b3f2
commit db07cbed6b
2 changed files with 8 additions and 4 deletions

View File

@ -48,4 +48,10 @@ char * strdup(const char *s);
int mkdir(const char *pathname, int mode);
#endif
/* do not use M_PI, use one of these instead: */
#define PI_F 3.1415926535897932384626433832795F
#define PI_D 3.1415926535897932384626433832795
#define PI_L 3.1415926535897932384626433832795L
#endif

View File

@ -28,8 +28,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <float.h>
#include <ctype.h>
#define PI_L 3.1415926535897932384626433832795L
int lovar(double xpct_x2)
{
int n = (int)(xpct_x2 * 500) + 1;
@ -51,10 +49,10 @@ double normalvariate(double mu, double sigma)
if (phase == 0) {
U = (rng_int() + 1.) / (RNG_RAND_MAX + 2.);
V = rng_int() / (RNG_RAND_MAX + 1.);
Z = sqrt(-2 * log(U)) * sin(2 * PI_L * V);
Z = sqrt(-2 * log(U)) * sin(2 * PI_D * V);
}
else {
Z = sqrt(-2 * log(U)) * cos(2 * PI_L * V);
Z = sqrt(-2 * log(U)) * cos(2 * PI_D * V);
}
phase = 1 - phase;