| 1 |
#include "f2c.h" |
| 2 |
|
| 3 |
#ifdef KR_headers |
| 4 |
#ifdef IEEE_drem |
| 5 |
double drem(); |
| 6 |
#else |
| 7 |
double floor(); |
| 8 |
#endif |
| 9 |
double d_mod(x,y) doublereal *x, *y; |
| 10 |
#else |
| 11 |
#ifdef IEEE_drem |
| 12 |
double drem(double, double); |
| 13 |
#else |
| 14 |
#undef abs |
| 15 |
#include "math.h" |
| 16 |
#ifdef __cplusplus |
| 17 |
extern "C" { |
| 18 |
#endif |
| 19 |
#endif |
| 20 |
double d_mod(doublereal *x, doublereal *y) |
| 21 |
#endif |
| 22 |
{ |
| 23 |
#ifdef IEEE_drem |
| 24 |
double xa, ya, z; |
| 25 |
if ((ya = *y) < 0.) |
| 26 |
ya = -ya; |
| 27 |
z = drem(xa = *x, ya); |
| 28 |
if (xa > 0) { |
| 29 |
if (z < 0) |
| 30 |
z += ya; |
| 31 |
} |
| 32 |
else if (z > 0) |
| 33 |
z -= ya; |
| 34 |
return z; |
| 35 |
#else |
| 36 |
double quotient; |
| 37 |
if( (quotient = *x / *y) >= 0) |
| 38 |
quotient = floor(quotient); |
| 39 |
else |
| 40 |
quotient = -floor(-quotient); |
| 41 |
return(*x - (*y) * quotient ); |
| 42 |
#endif |
| 43 |
} |
| 44 |
#ifdef __cplusplus |
| 45 |
} |
| 46 |
#endif |