define PI, because M_PI is not to be depended on

This commit is contained in:
Enno Rehling 2017-05-04 08:22:20 +02:00
parent 692c9a1dac
commit 7ad5c4b3f2
2 changed files with 4 additions and 3 deletions

View File

@ -21,7 +21,6 @@
#pragma warning(disable: 4457) // declaration hides function parameter
#pragma warning(disable: 4459) // declaration hides global
#else /* assume gcc */
#define __USE_BSD
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# define va_copy(a,b) __va_copy(a,b)
#endif

View File

@ -28,6 +28,8 @@ 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;
@ -49,10 +51,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 * M_PI * V);
Z = sqrt(-2 * log(U)) * sin(2 * PI_L * V);
}
else {
Z = sqrt(-2 * log(U)) * cos(2 * M_PI * V);
Z = sqrt(-2 * log(U)) * cos(2 * PI_L * V);
}
phase = 1 - phase;