ack/lang/fortran/lib/libF77/r_mod.c

27 lines
417 B
C
Raw Permalink Normal View History

1991-10-07 16:59:33 +00:00
#include "f2c.h"
double r_mod(x,y)
real *x, *y;
{
#ifdef IEEE_drem
double drem(), 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;
#else
double floor(), quotient;
if( (quotient = (double)*x / *y) >= 0)
quotient = floor(quotient);
else
quotient = -floor(-quotient);
return(*x - (*y) * quotient );
#endif
}