1 /* origin: FreeBSD /usr/src/lib/msun/src/e_remainderf.c */
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
13 * ====================================================
18 static const float zero = 0.0;
20 float remainderf(float x, float p)
26 GET_FLOAT_WORD(hx, x);
27 GET_FLOAT_WORD(hp, p);
32 /* purge off exception values */
33 if (hp == 0) /* p = 0 */
35 if (hx >= 0x7f800000 || hp > 0x7f800000) /* x not finite, p is NaN */
36 // FIXME: why long double?
37 return ((long double)x*p)/((long double)x*p);
40 x = fmodf(x, p + p); /* now x < 2p */
45 if (hp < 0x01000000) {
59 GET_FLOAT_WORD(hx, x);
60 if ((hx & 0x7fffffff) == 0)
62 SET_FLOAT_WORD(x, hx ^ sx);