summaryrefslogtreecommitdiff
path: root/gnu/lib/libf2c/libF77/r_mod.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2004-02-29 19:27:25 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2004-02-29 19:27:25 +0000
commit06bbcaeb9d33fce156543e2d84b1df4a0a9e1127 (patch)
tree8614ca58169c994e07adc995d206e8434b020c5d /gnu/lib/libf2c/libF77/r_mod.c
parent4a95829907bd98f42503d9e6f91af8df4c9313ab (diff)
Import of libf2c from gcc3.3.2
Diffstat (limited to 'gnu/lib/libf2c/libF77/r_mod.c')
-rw-r--r--gnu/lib/libf2c/libF77/r_mod.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gnu/lib/libf2c/libF77/r_mod.c b/gnu/lib/libf2c/libF77/r_mod.c
new file mode 100644
index 00000000000..faea344a7b7
--- /dev/null
+++ b/gnu/lib/libf2c/libF77/r_mod.c
@@ -0,0 +1,40 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+#ifdef IEEE_drem
+double drem();
+#else
+double floor();
+#endif
+double r_mod(x,y) real *x, *y;
+#else
+#ifdef IEEE_drem
+double drem(double, double);
+#else
+#undef abs
+#include <math.h>
+#endif
+double r_mod(real *x, real *y)
+#endif
+{
+#ifdef IEEE_drem
+ 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;
+#else
+ double quotient;
+ if( (quotient = (double)*x / *y) >= 0)
+ quotient = floor(quotient);
+ else
+ quotient = -floor(-quotient);
+ return(*x - (*y) * quotient );
+#endif
+}