about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/s_nearbyint.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-03-13 14:12:44 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-03-13 14:12:44 +0000
commitf453b98b6bf698ddb4d49cd3dc0f94d2da2a8968 (patch)
treeb14dc65111884a7d94642b63741aa015cd41463d /sysdeps/ieee754/dbl-64/s_nearbyint.c
parent8e59da90ce7ef7b4226b9516116353cfceb5bb1c (diff)
downloadglibc-f453b98b6bf698ddb4d49cd3dc0f94d2da2a8968.tar.gz
glibc-f453b98b6bf698ddb4d49cd3dc0f94d2da2a8968.tar.xz
glibc-f453b98b6bf698ddb4d49cd3dc0f94d2da2a8968.zip
Clean up dbl-64 rint, nearbyint.
Diffstat (limited to 'sysdeps/ieee754/dbl-64/s_nearbyint.c')
-rw-r--r--sysdeps/ieee754/dbl-64/s_nearbyint.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c
index d780150a90..60afafdedd 100644
--- a/sysdeps/ieee754/dbl-64/s_nearbyint.c
+++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c
@@ -38,18 +38,12 @@ double __nearbyint(double x)
 {
 	fenv_t env;
 	int32_t i0,j0,sx;
-	u_int32_t i,i1;
 	double w,t;
-	EXTRACT_WORDS(i0,i1,x);
+	GET_HIGH_WORD(i0,x);
 	sx = (i0>>31)&1;
 	j0 = ((i0>>20)&0x7ff)-0x3ff;
-	if(j0<20) {
+	if(j0<52) {
 	    if(j0<0) {
-		if(((i0&0x7fffffff)|i1)==0) return x;
-		i1 |= (i0&0x0fffff);
-		i0 &= 0xfffe0000;
-		i0 |= ((i1|-i1)>>12)&0x80000;
-		SET_HIGH_WORD(x,i0);
 		feholdexcept (&env);
 	        w = TWO52[sx]+x;
 	        t =  w-TWO52[sx];
@@ -57,32 +51,11 @@ double __nearbyint(double x)
 		GET_HIGH_WORD(i0,t);
 		SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
 	        return t;
-	    } else {
-		i = (0x000fffff)>>j0;
-		if(((i0&i)|i1)==0) return x; /* x is integral */
-		i>>=1;
-		if(((i0&i)|i1)!=0) {
-		  if (j0==19)
-		    i1 = 0x40000000;
-		  else if (j0<18)
-		    i0 = (i0&(~i))|((0x20000)>>j0);
-		  else
-		    {
-		      i0 &= ~i;
-		      i1 = 0x80000000;
-		    }
-		}
 	    }
-	} else if (j0>51) {
+	} else {
 	    if(j0==0x400) return x+x;	/* inf or NaN */
 	    else return x;		/* x is integral */
-	} else {
-	    i = ((u_int32_t)(0xffffffff))>>(j0-20);
-	    if((i1&i)==0) return x;	/* x is integral */
-	    i>>=1;
-	    if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
 	}
-	INSERT_WORDS(x,i0,i1);
 	feholdexcept (&env);
 	w = TWO52[sx]+x;
 	t = w-TWO52[sx];