[BACK]Return to s_rint.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libm / src

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libm/src/s_rint.c between version 1.11 and 1.12

version 1.11, 2002/05/26 22:01:58 version 1.12, 2008/04/25 22:21:53
Line 37  TWO52[2]={
Line 37  TWO52[2]={
 double  double
 rint(double x)  rint(double x)
 {  {
         int32_t i0,j0,sx;          int32_t i0,jj0,sx;
         u_int32_t i,i1;          u_int32_t i,i1;
         double w,t;          double w,t;
         EXTRACT_WORDS(i0,i1,x);          EXTRACT_WORDS(i0,i1,x);
         sx = (i0>>31)&1;          sx = (i0>>31)&1;
         j0 = ((i0>>20)&0x7ff)-0x3ff;          jj0 = ((i0>>20)&0x7ff)-0x3ff;
         if(j0<20) {          if(jj0<20) {
             if(j0<0) {              if(jj0<0) {
                 if(((i0&0x7fffffff)|i1)==0) return x;                  if(((i0&0x7fffffff)|i1)==0) return x;
                 i1 |= (i0&0x0fffff);                  i1 |= (i0&0x0fffff);
                 i0 &= 0xfffe0000;                  i0 &= 0xfffe0000;
Line 56  rint(double x)
Line 56  rint(double x)
                 SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));                  SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
                 return t;                  return t;
             } else {              } else {
                 i = (0x000fffff)>>j0;                  i = (0x000fffff)>>jj0;
                 if(((i0&i)|i1)==0) return x; /* x is integral */                  if(((i0&i)|i1)==0) return x; /* x is integral */
                 i>>=1;                  i>>=1;
                 if(((i0&i)|i1)!=0) {                  if(((i0&i)|i1)!=0) {
                     if(j0==19) i1 = 0x40000000; else                      if(jj0==19) i1 = 0x40000000; else
                     i0 = (i0&(~i))|((0x20000)>>j0);                      i0 = (i0&(~i))|((0x20000)>>jj0);
                 }                  }
             }              }
         } else if (j0>51) {          } else if (jj0>51) {
             if(j0==0x400) return x+x;   /* inf or NaN */              if(jj0==0x400) return x+x;  /* inf or NaN */
             else return x;              /* x is integral */              else return x;              /* x is integral */
         } else {          } else {
             i = ((u_int32_t)(0xffffffff))>>(j0-20);              i = ((u_int32_t)(0xffffffff))>>(jj0-20);
             if((i1&i)==0) return x;     /* x is integral */              if((i1&i)==0) return x;     /* x is integral */
             i>>=1;              i>>=1;
             if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));              if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(jj0-20));
         }          }
         INSERT_WORDS(x,i0,i1);          INSERT_WORDS(x,i0,i1);
         w = TWO52[sx]+x;          w = TWO52[sx]+x;

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

CVSweb <webmaster@jp.NetBSD.org>