add -a flag
[unix-history] / usr / src / usr.bin / f77 / libF77 / r_mod.c
CommitLineData
3a1bfc49 1/*
e309c71b
RE
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 *
af857331 6 * @(#)r_mod.c 5.4 %G%
3a1bfc49
DW
7 */
8
af857331 9#ifndef tahoe
e2fcf16d
JB
10float flt_retval;
11
46452188 12float r_mod(x,y)
3a1bfc49
DW
13float *x, *y;
14{
15double floor(), quotient = *x / *y;
16if (quotient >= 0.0)
17 quotient = floor(quotient);
18else
19 quotient = -floor(-quotient);
e2fcf16d
JB
20flt_retval = *x - (*y) * quotient ;
21return(flt_retval);
3a1bfc49 22}
af857331
KM
23
24#else tahoe
25
26/* THIS IS BASED ON THE TAHOE REPR. FOR FLOATING POINT */
27#include <tahoemath/FP.h>
28
29double r_mod(x,y)
30float *x, *y;
31{
32double floor(), quotient = *x / *y;
33if (quotient >= 0.0)
34 quotient = floor(quotient);
35else {
36 *(unsigned long *)&quotient ^= SIGN_BIT;
37 quotient = floor(quotient);
38 if (quotient != 0)
39 *(unsigned long *)&quotient ^= SIGN_BIT;
40 }
41return(*x - (*y) * quotient );
42}
43#endif tahoe