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 * ====================================================
21 __int32_t signbit
, w
, exponent_less_127
;
25 /* Extract sign bit. */
26 signbit
= w
& 0x80000000;
28 /* Extract exponent field. */
29 exponent_less_127
= ((w
& 0x7f800000) >> 23) - 127;
31 if (exponent_less_127
< 23)
33 if (exponent_less_127
< 0)
35 /* -1 < x < 1, so result is +0 or -0. */
36 SET_FLOAT_WORD(x
, signbit
);
40 SET_FLOAT_WORD(x
, signbit
| (w
& ~(0x007fffff >> exponent_less_127
)));
45 if (exponent_less_127
== 128)
46 /* x is NaN or infinite. */
49 /* All bits in the fraction field are relevant. */
54 #ifdef _DOUBLE_IS_32BITS
57 double trunc(double x
)
63 return (double) truncf((float) x
);
66 #endif /* defined(_DOUBLE_IS_32BITS) */