4 double fmod(double x
, double y
)
6 union {double f
; uint64_t i
;} ux
= {x
}, uy
= {y
};
7 int ex
= ux
.i
>>52 & 0x7ff;
8 int ey
= uy
.i
>>52 & 0x7ff;
12 /* in the followings uxi should be ux.i, but then gcc wrongly adds */
13 /* float load/store to inner loops ruining performance and code size */
16 if (uy
.i
<<1 == 0 || isnan(y
) || ex
== 0x7ff)
18 if (uxi
<<1 <= uy
.i
<<1) {
19 if (uxi
<<1 == uy
.i
<<1)
24 /* normalize x and y */
26 for (i
= uxi
<<12; i
>>63 == 0; ex
--, i
<<= 1);
33 for (i
= uy
.i
<<12; i
>>63 == 0; ey
--, i
<<= 1);
41 for (; ex
> ey
; ex
--) {
56 for (; uxi
>>52 == 0; uxi
<<= 1, ex
--);
61 uxi
|= (uint64_t)ex
<< 52;
65 uxi
|= (uint64_t)sx
<< 63;