|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)r_mod.c 5.4 11/3/86 ! 7: */ ! 8: ! 9: #ifndef tahoe ! 10: float flt_retval; ! 11: ! 12: float r_mod(x,y) ! 13: float *x, *y; ! 14: { ! 15: double floor(), quotient = *x / *y; ! 16: if (quotient >= 0.0) ! 17: quotient = floor(quotient); ! 18: else ! 19: quotient = -floor(-quotient); ! 20: flt_retval = *x - (*y) * quotient ; ! 21: return(flt_retval); ! 22: } ! 23: ! 24: #else tahoe ! 25: ! 26: /* THIS IS BASED ON THE TAHOE REPR. FOR FLOATING POINT */ ! 27: #include <tahoemath/FP.h> ! 28: ! 29: double r_mod(x,y) ! 30: float *x, *y; ! 31: { ! 32: double floor(), quotient = *x / *y; ! 33: if (quotient >= 0.0) ! 34: quotient = floor(quotient); ! 35: else { ! 36: *(unsigned long *)"ient ^= SIGN_BIT; ! 37: quotient = floor(quotient); ! 38: if (quotient != 0) ! 39: *(unsigned long *)"ient ^= SIGN_BIT; ! 40: } ! 41: return(*x - (*y) * quotient ); ! 42: } ! 43: #endif tahoe
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.