Print this page




  63         if (sx && (rm == FE_UPWARD || rm == FE_DOWNWARD))
  64                 rm = (FE_UPWARD + FE_DOWNWARD) - rm;
  65 
  66         /* handle |x| < 1 */
  67         if (hx < 0x3f800000) {
  68                 if (rm == FE_UPWARD || (rm == FE_TONEAREST && hx > 0x3f000000))
  69                         xx.i = sx | 0x3f800000;
  70                 else
  71                         xx.i = sx;
  72                 return (xx.f);
  73         }
  74 
  75         /* round x at the integer bit */
  76         i = 1 << (0x96 - (hx >> 23));
  77         frac = hx & (i - 1);
  78         if (!frac)
  79                 return (x);
  80 
  81         hx &= ~(i - 1);
  82         if (rm == FE_UPWARD || (rm == FE_TONEAREST && (frac > (i >> 1) ||
  83                 (frac == (i >> 1)) && (hx & i))))
  84                 xx.i = sx | (hx + i);
  85         else
  86                 xx.i = sx | hx;
  87         return (xx.f);
  88 }
  89 
  90 #if 0
  91 
  92 /*
  93  * Alternate implementations for SPARC, x86, using fp ops.  These may
  94  * be faster depending on how expensive saving and restoring the fp
  95  * modes and status flags is.
  96  */
  97 
  98 #include "libm.h"
  99 #include "fma.h"
 100 
 101 #if defined(__sparc)
 102 
 103 float




  63         if (sx && (rm == FE_UPWARD || rm == FE_DOWNWARD))
  64                 rm = (FE_UPWARD + FE_DOWNWARD) - rm;
  65 
  66         /* handle |x| < 1 */
  67         if (hx < 0x3f800000) {
  68                 if (rm == FE_UPWARD || (rm == FE_TONEAREST && hx > 0x3f000000))
  69                         xx.i = sx | 0x3f800000;
  70                 else
  71                         xx.i = sx;
  72                 return (xx.f);
  73         }
  74 
  75         /* round x at the integer bit */
  76         i = 1 << (0x96 - (hx >> 23));
  77         frac = hx & (i - 1);
  78         if (!frac)
  79                 return (x);
  80 
  81         hx &= ~(i - 1);
  82         if (rm == FE_UPWARD || (rm == FE_TONEAREST && (frac > (i >> 1) ||
  83                 ((frac == (i >> 1)) && (hx & i)))))
  84                 xx.i = sx | (hx + i);
  85         else
  86                 xx.i = sx | hx;
  87         return (xx.f);
  88 }
  89 
  90 #if 0
  91 
  92 /*
  93  * Alternate implementations for SPARC, x86, using fp ops.  These may
  94  * be faster depending on how expensive saving and restoring the fp
  95  * modes and status flags is.
  96  */
  97 
  98 #include "libm.h"
  99 #include "fma.h"
 100 
 101 #if defined(__sparc)
 102 
 103 float