110532Sdlw /* 222962Skre * Copyright (c) 1980 Regents of the University of California. 322962Skre * All rights reserved. The Berkeley software License Agreement 422962Skre * specifies the terms and conditions for redistribution. 522962Skre * 6*45967Sbostic * @(#)r_mod.c 5.5 01/15/91 710532Sdlw */ 810532Sdlw 929969Smckusick #ifndef tahoe 1023856Sjerry float flt_retval; 1123856Sjerry 1223854Sjerry float r_mod(x,y) 1310532Sdlw float *x, *y; 1410532Sdlw { 1510532Sdlw double floor(), quotient = *x / *y; 1610532Sdlw if (quotient >= 0.0) 1710532Sdlw quotient = floor(quotient); 1810532Sdlw else 1910532Sdlw quotient = -floor(-quotient); 2023856Sjerry flt_retval = *x - (*y) * quotient ; 2123856Sjerry return(flt_retval); 2210532Sdlw } 2329969Smckusick 24*45967Sbostic #else 2529969Smckusick 2629969Smckusick /* THIS IS BASED ON THE TAHOE REPR. FOR FLOATING POINT */ 27*45967Sbostic #include <tahoe/math/FP.h> 2829969Smckusick 2929969Smckusick double r_mod(x,y) 3029969Smckusick float *x, *y; 3129969Smckusick { 3229969Smckusick double floor(), quotient = *x / *y; 3329969Smckusick if (quotient >= 0.0) 3429969Smckusick quotient = floor(quotient); 3529969Smckusick else { 3629969Smckusick *(unsigned long *)"ient ^= SIGN_BIT; 3729969Smckusick quotient = floor(quotient); 3829969Smckusick if (quotient != 0) 3929969Smckusick *(unsigned long *)"ient ^= SIGN_BIT; 4029969Smckusick } 4129969Smckusick return(*x - (*y) * quotient ); 4229969Smckusick } 43*45967Sbostic #endif 44