4 float remquof(float x
, float y
, int *quo
)
6 union {float f
; uint32_t i
;} ux
= {x
}, uy
= {y
};
7 int ex
= ux
.i
>>23 & 0xff;
8 int ey
= uy
.i
>>23 & 0xff;
16 if (uy
.i
<<1 == 0 || isnan(y
) || ex
== 0xff)
21 /* normalize x and y */
23 for (i
= uxi
<<9; i
>>31 == 0; ex
--, i
<<= 1);
30 for (i
= uy
.i
<<9; i
>>31 == 0; ey
--, i
<<= 1);
45 for (; ex
> ey
; ex
--) {
62 for (; uxi
>>23 == 0; uxi
<<= 1, ex
--);
64 /* scale result and decide between |x| and |x|-|y| */
67 uxi
|= (uint32_t)ex
<< 23;
75 if (ex
== ey
|| (ex
+1 == ey
&& (2*x
> y
|| (2*x
== y
&& q
%2)))) {
80 *quo
= sx
^sy
? -(int)q
: (int)q
;