correct #ifdef's (from jim mckie)
[unix-history] / usr / src / usr.bin / f77 / libF77 / r_mod.c
index 125cd21..d664bc6 100644 (file)
@@ -3,9 +3,10 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)r_mod.c     5.3     %G%
+ *     @(#)r_mod.c     5.4     %G%
  */
 
  */
 
+#ifndef tahoe
 float flt_retval;
 
 float r_mod(x,y)
 float flt_retval;
 
 float r_mod(x,y)
@@ -19,3 +20,24 @@ else
 flt_retval = *x - (*y) * quotient ;
 return(flt_retval);
 }
 flt_retval = *x - (*y) * quotient ;
 return(flt_retval);
 }
+
+#else tahoe
+
+/*   THIS IS BASED ON THE TAHOE REPR. FOR FLOATING POINT */
+#include <tahoemath/FP.h>
+
+double r_mod(x,y)
+float *x, *y;
+{
+double floor(), quotient = *x / *y;
+if (quotient >= 0.0)
+       quotient = floor(quotient);
+else {
+       *(unsigned long *)&quotient ^= SIGN_BIT;
+       quotient = floor(quotient);
+       if (quotient != 0)
+               *(unsigned long *)&quotient ^= SIGN_BIT;
+       }
+return(*x - (*y) * quotient );
+}
+#endif tahoe