freebsd-nq/contrib/libf2c/libF77/d_mod.c

34 lines
525 B
C
Raw Normal View History

1999-09-18 10:51:31 +00:00
#include "f2c.h"
#ifdef IEEE_drem
2003-07-11 03:42:19 +00:00
double drem (double, double);
1999-09-18 10:51:31 +00:00
#else
#undef abs
#include <math.h>
#endif
2003-07-11 03:42:19 +00:00
double
d_mod (doublereal * x, doublereal * y)
1999-09-18 10:51:31 +00:00
{
#ifdef IEEE_drem
2003-07-11 03:42:19 +00: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;
1999-09-18 10:51:31 +00:00
#else
2003-07-11 03:42:19 +00:00
double quotient;
if ((quotient = *x / *y) >= 0)
quotient = floor (quotient);
else
quotient = -floor (-quotient);
return (*x - (*y) * quotient);
1999-09-18 10:51:31 +00:00
#endif
}