8 #if (__BYTE_ORDER == __BIG_ENDIAN)
19 static const unsigned long int signMask = 0x80000000ul;
20 static const double twoTo52 = 4503599627370496.0;
22 /*******************************************************************************
24 * The function trunc truncates its double argument to integral value *
25 * and returns the result in double format. This function signals *
26 * inexact if an ordered return value is not equal to the operand. *
28 *******************************************************************************/
30 libm_hidden_proto(trunc)
31 double trunc ( double x )
33 DblInHex argument,OldEnvironment;
35 register unsigned long int xhi;
36 register long int target;
39 xhi = argument.words.hi & 0x7fffffffUL; // xhi <- high half of |x|
40 target = ( argument.words.hi < signMask ); // flag positive sign
42 if ( xhi < 0x43300000ul )
43 /*******************************************************************************
45 *******************************************************************************/
47 if ( xhi < 0x3ff00000ul )
48 /*******************************************************************************
50 *******************************************************************************/
52 if ( ( xhi | argument.words.lo ) != 0ul )
53 { // raise deserved INEXACT
54 __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
55 OldEnvironment.words.lo |= 0x02000000ul;
56 __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
58 if ( target ) // return properly signed zero
63 /*******************************************************************************
64 * Is 1.0 < |x| < 2.0^52? *
65 *******************************************************************************/
68 y = ( x + twoTo52 ) - twoTo52; // round at binary point
77 y = ( x - twoTo52 ) + twoTo52; // round at binary point.
84 /*******************************************************************************
85 * Is |x| >= 2.0^52 or x is a NaN. *
86 *******************************************************************************/
89 libm_hidden_def(trunc)