xref: /csrg-svn/usr.bin/f77/libF77/d_mod.c (revision 45967)
110463Sdlw /*
222863Skre  * Copyright (c) 1980 Regents of the University of California.
322863Skre  * All rights reserved.  The Berkeley software License Agreement
422863Skre  * specifies the terms and conditions for redistribution.
522863Skre  *
6*45967Sbostic  *	@(#)d_mod.c	5.4	01/15/91
710463Sdlw  */
829963Smckusick #ifdef tahoe
9*45967Sbostic #include <tahoe/math/FP.h>
10*45967Sbostic #endif
1110463Sdlw 
1210463Sdlw double d_mod(x,y)
1310463Sdlw double *x, *y;
1410463Sdlw {
1510463Sdlw double floor(), quotient = *x / *y;
1610463Sdlw if (quotient >= 0.0)
1710463Sdlw 	quotient = floor(quotient);
1829963Smckusick else {
1929963Smckusick #ifndef tahoe
2010463Sdlw 	quotient = -floor(-quotient);
2129963Smckusick #else tahoe
2229963Smckusick 	*(unsigned long *)&quotient ^= SIGN_BIT;
2329963Smckusick 	quotient = floor(quotient);
2429963Smckusick 	if (quotient !=0)
2529963Smckusick 		*(unsigned long *)&quotient ^= SIGN_BIT;
2631042Ssam #endif tahoe
2729963Smckusick }
2810463Sdlw return(*x - (*y) * quotient );
2910463Sdlw }
30