1998-02-01 02:37:08 +01:00
|
|
|
#include "f2c.h"
|
|
|
|
|
|
|
|
#ifdef IEEE_drem
|
2002-06-01 14:38:32 +02:00
|
|
|
double drem (double, double);
|
1998-02-01 02:37:08 +01:00
|
|
|
#else
|
|
|
|
#undef abs
|
|
|
|
#include <math.h>
|
|
|
|
#endif
|
2002-06-01 14:38:32 +02:00
|
|
|
double
|
|
|
|
d_mod (doublereal * x, doublereal * y)
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
|
|
|
#ifdef IEEE_drem
|
2002-06-01 14:38:32 +02:00
|
|
|
double xa, ya, z;
|
|
|
|
if ((ya = *y) < 0.)
|
|
|
|
ya = -ya;
|
|
|
|
z = drem (xa = *x, ya);
|
|
|
|
if (xa > 0)
|
|
|
|
{
|
|
|
|
if (z < 0)
|
|
|
|
z += ya;
|
|
|
|
}
|
|
|
|
else if (z > 0)
|
|
|
|
z -= ya;
|
|
|
|
return z;
|
1998-02-01 02:37:08 +01:00
|
|
|
#else
|
2002-06-01 14:38:32 +02:00
|
|
|
double quotient;
|
|
|
|
if ((quotient = *x / *y) >= 0)
|
|
|
|
quotient = floor (quotient);
|
|
|
|
else
|
|
|
|
quotient = -floor (-quotient);
|
|
|
|
return (*x - (*y) * quotient);
|
1998-02-01 02:37:08 +01:00
|
|
|
#endif
|
|
|
|
}
|