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 * ====================================================
15 long int lroundf(float x
)
21 __int32_t exponent_less_127
;
26 GET_FLOAT_WORD (w
, x
);
27 exponent_less_127
= ((w
& 0x7f800000) >> 23) - 127;
28 sign
= (w
& 0x80000000) != 0 ? -1 : 1;
32 if (exponent_less_127
< (int)((8 * sizeof (long int)) - 1))
34 if (exponent_less_127
< 0)
35 return exponent_less_127
< -1 ? 0 : sign
;
36 else if (exponent_less_127
>= 23)
37 result
= (long int) w
<< (exponent_less_127
- 23);
40 w
+= 0x400000 >> exponent_less_127
;
41 result
= w
>> (23 - exponent_less_127
);
50 #ifdef _DOUBLE_IS_32BITS
53 long int lround(double x
)
59 return lroundf((float) x
);
62 #endif /* defined(_DOUBLE_IS_32BITS) */