2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libf2c / libF77 / d_mod.c
blob15cedefadd1151497c0b042752f5ae6149adbda5
1 #include "f2c.h"
3 #ifdef IEEE_drem
4 double drem (double, double);
5 #else
6 #undef abs
7 #include <math.h>
8 #endif
9 double
10 d_mod (doublereal * x, doublereal * y)
12 #ifdef IEEE_drem
13 double xa, ya, z;
14 if ((ya = *y) < 0.)
15 ya = -ya;
16 z = drem (xa = *x, ya);
17 if (xa > 0)
19 if (z < 0)
20 z += ya;
22 else if (z > 0)
23 z -= ya;
24 return z;
25 #else
26 double quotient;
27 if ((quotient = *x / *y) >= 0)
28 quotient = floor (quotient);
29 else
30 quotient = -floor (-quotient);
31 return (*x - (*y) * quotient);
32 #endif