Commit | Line | Data |
---|---|---|
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 |
10 | float flt_retval; |
11 | ||
46452188 | 12 | float r_mod(x,y) |
3a1bfc49 DW |
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); | |
e2fcf16d JB |
20 | flt_retval = *x - (*y) * quotient ; |
21 | return(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 | ||
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 |