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 * ====================================================
14 * Return x rounded toward 0 to integral value
18 * Inexact flag raised if x not equal to trunc(x).
24 #include "math_private.h"
26 static const double huge = 1.0e300;
33 EXTRACT_WORDS(i0,i1,x);
34 j0 = ((i0>>20)&0x7ff)-0x3ff;
36 if(j0<0) { /* raise inexact if x != 0 */
37 if(huge+x>0.0) {/* |x|<1, so return 0*sign(x) */
43 if(((i0&i)|i1)==0) return x; /* x is integral */
44 if(huge+x>0.0) { /* raise inexact flag */
49 if(j0==0x400) return x+x; /* inf or NaN */
50 else return x; /* x is integral */
52 i = ((u_int32_t)(0xffffffff))>>(j0-20);
53 if((i1&i)==0) return x; /* x is integral */
54 if(huge+x>0.0) /* raise inexact flag */
57 INSERT_WORDS(x,i0,i1);
61 #if LDBL_MANT_DIG == 53
62 __weak_reference(trunc, truncl);