Rev 4872 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | |
2 | /* |
||
3 | * ==================================================== |
||
4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
||
5 | * |
||
6 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
||
7 | * Permission to use, copy, modify, and distribute this |
||
8 | * software is freely granted, provided that this notice |
||
9 | * is preserved. |
||
10 | * ==================================================== |
||
11 | */ |
||
12 | |||
13 | |||
14 | FUNCTION |
||
15 | < |
||
16 | |||
17 | |||
18 | fmod |
||
19 | INDEX |
||
20 | fmodf |
||
21 | |||
22 | |||
23 | #include |
||
24 | double fmod(double <[x]>, double <[y]>) |
||
25 | float fmodf(float <[x]>, float <[y]>) |
||
26 | |||
27 | |||
28 | #include |
||
29 | double fmod(<[x]>, <[y]>) |
||
30 | double (<[x]>, <[y]>); |
||
31 | |||
32 | |||
33 | float (<[x]>, <[y]>); |
||
34 | |||
35 | |||
36 | The < |
||
37 | remainder of <[x]>/<[y]> (<[x]> modulo <[y]>). |
||
38 | |||
39 | |||
40 | The < |
||
41 | @ifnottex |
||
42 | <[x]>-<[i]>*<[y]>, |
||
43 | @end ifnottex |
||
44 | @tex |
||
45 | $x-i\times y$, |
||
46 | @end tex |
||
47 | for the largest integer <[i]> such that, if <[y]> is nonzero, the |
||
48 | result has the same sign as <[x]> and magnitude less than the |
||
49 | magnitude of <[y]>. |
||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | < |
||
57 | */ |
||
58 | |||
59 | |||
60 | * wrapper fmod(x,y) |
||
61 | */ |
||
62 | |||
63 | |||
64 | #include |
||
65 | |||
66 | |||
67 | |||
68 | |||
69 | double fmod(double x, double y) /* wrapper fmod */ |
||
70 | #else |
||
71 | double fmod(x,y) /* wrapper fmod */ |
||
72 | double x,y; |
||
73 | #endif |
||
74 | { |
||
75 | #ifdef _IEEE_LIBM |
||
76 | return __ieee754_fmod(x,y); |
||
77 | #else |
||
78 | double z; |
||
79 | struct exception exc; |
||
80 | z = __ieee754_fmod(x,y); |
||
81 | if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; |
||
82 | if(y==0.0) { |
||
83 | /* fmod(x,0) */ |
||
84 | exc.type = DOMAIN; |
||
85 | exc.name = "fmod"; |
||
86 | exc.arg1 = x; |
||
87 | exc.arg2 = y; |
||
88 | exc.err = 0; |
||
89 | if (_LIB_VERSION == _SVID_) |
||
90 | exc.retval = x; |
||
91 | else |
||
92 | exc.retval = 0.0/0.0; |
||
93 | if (_LIB_VERSION == _POSIX_) |
||
94 | errno = EDOM; |
||
95 | else if (!matherr(&exc)) { |
||
96 | errno = EDOM; |
||
97 | } |
||
98 | if (exc.err != 0) |
||
99 | errno = exc.err; |
||
100 | return exc.retval; |
||
101 | } else |
||
102 | return z; |
||
103 | #endif |
||
104 | } |
||
105 | |||
106 | |||
107 |