Print this page




  83                         (hx >= 0x3fe00000 && ((hx & 0xfffff) | xx.i[LOWORD]))))
  84                         xx.i[HIWORD] = sx | 0x3ff00000;
  85                 else
  86                         xx.i[HIWORD] = sx;
  87                 xx.i[LOWORD] = 0;
  88                 return (xx.d);
  89         }
  90 
  91         /* round x at the integer bit */
  92         j = 0x433 - (hx >> 20);
  93         if (j >= 32) {
  94                 i = 1 << (j - 32);
  95                 frac = ((xx.i[HIWORD] << 1) << (63 - j)) |
  96                         (xx.i[LOWORD] >> (j - 32));
  97                 if (xx.i[LOWORD] & (i - 1))
  98                         frac |= 1;
  99                 if (!frac)
 100                         return (x);
 101                 xx.i[LOWORD] = 0;
 102                 xx.i[HIWORD] &= ~(i - 1);
 103                 if (rm == FE_UPWARD || (rm == FE_TONEAREST &&
 104                         (frac > 0x80000000u || (frac == 0x80000000) &&
 105                         (xx.i[HIWORD] & i))))
 106                         xx.i[HIWORD] += i;
 107         } else {
 108                 i = 1 << j;
 109                 frac = (xx.i[LOWORD] << 1) << (31 - j);
 110                 if (!frac)
 111                         return (x);
 112                 xx.i[LOWORD] &= ~(i - 1);
 113                 if (rm == FE_UPWARD || (rm == FE_TONEAREST &&
 114                         (frac > 0x80000000u || (frac == 0x80000000) &&
 115                         (xx.i[LOWORD] & i)))) {
 116                         xx.i[LOWORD] += i;
 117                         if (xx.i[LOWORD] == 0)
 118                                 xx.i[HIWORD]++;
 119                 }
 120         }
 121         return (xx.d);
 122 }
 123 
 124 #if 0
 125 
 126 /*
 127 *  Alternate implementations for SPARC, x86, using fp ops.  These may
 128 *  be faster depending on how expensive saving and restoring the fp
 129 *  modes and status flags is.
 130 */
 131 
 132 #include "libm.h"
 133 #include "fma.h"
 134 
 135 #if defined(__sparc)




  83                         (hx >= 0x3fe00000 && ((hx & 0xfffff) | xx.i[LOWORD]))))
  84                         xx.i[HIWORD] = sx | 0x3ff00000;
  85                 else
  86                         xx.i[HIWORD] = sx;
  87                 xx.i[LOWORD] = 0;
  88                 return (xx.d);
  89         }
  90 
  91         /* round x at the integer bit */
  92         j = 0x433 - (hx >> 20);
  93         if (j >= 32) {
  94                 i = 1 << (j - 32);
  95                 frac = ((xx.i[HIWORD] << 1) << (63 - j)) |
  96                         (xx.i[LOWORD] >> (j - 32));
  97                 if (xx.i[LOWORD] & (i - 1))
  98                         frac |= 1;
  99                 if (!frac)
 100                         return (x);
 101                 xx.i[LOWORD] = 0;
 102                 xx.i[HIWORD] &= ~(i - 1);
 103                 if ((rm == FE_UPWARD) || ((rm == FE_TONEAREST) &&
 104                         ((frac > 0x80000000u) || ((frac == 0x80000000) &&
 105                         (xx.i[HIWORD] & i)))))
 106                         xx.i[HIWORD] += i;
 107         } else {
 108                 i = 1 << j;
 109                 frac = (xx.i[LOWORD] << 1) << (31 - j);
 110                 if (!frac)
 111                         return (x);
 112                 xx.i[LOWORD] &= ~(i - 1);
 113                 if ((rm == FE_UPWARD) || ((rm == FE_TONEAREST) &&
 114                         (frac > 0x80000000u || ((frac == 0x80000000) &&
 115                         (xx.i[LOWORD] & i))))) {
 116                         xx.i[LOWORD] += i;
 117                         if (xx.i[LOWORD] == 0)
 118                                 xx.i[HIWORD]++;
 119                 }
 120         }
 121         return (xx.d);
 122 }
 123 
 124 #if 0
 125 
 126 /*
 127 *  Alternate implementations for SPARC, x86, using fp ops.  These may
 128 *  be faster depending on how expensive saving and restoring the fp
 129 *  modes and status flags is.
 130 */
 131 
 132 #include "libm.h"
 133 #include "fma.h"
 134 
 135 #if defined(__sparc)