2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
22 /* Most significant word, least significant word. */
23 int exponent_less_127
;
27 /* Extract exponent field. */
28 exponent_less_127
= (int)((w
& 0x7f800000) >> 23) - 127;
30 if (exponent_less_127
< 23)
32 if (exponent_less_127
< 0)
35 if (exponent_less_127
== -1)
36 /* Result is +1.0 or -1.0. */
37 w
|= ((__uint32_t
)127 << 23);
41 unsigned int exponent_mask
= 0x007fffff >> exponent_less_127
;
42 if ((w
& exponent_mask
) == 0)
43 /* x has an integral value. */
46 w
+= 0x00400000 >> exponent_less_127
;
52 if (exponent_less_127
== 128)
53 /* x is NaN or infinite. */
62 #ifdef _DOUBLE_IS_32BITS
65 double round(double x
)
71 return (double) roundf((float) x
);
74 #endif /* defined(_DOUBLE_IS_32BITS) */