about summary refs log tree commit diff
path: root/src/math/atan2l.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2012-12-16 20:28:43 +0100
committerSzabolcs Nagy <nsz@port70.net>2012-12-16 20:28:43 +0100
commitc6383b7b10303457306932584fc23f24b5153a81 (patch)
treeebc0a95cb34bcb501060b1679f14a19c7d92c91c /src/math/atan2l.c
parentd8a7619e371ff0f226200f6316abb46dd1192f3d (diff)
downloadmusl-c6383b7b10303457306932584fc23f24b5153a81.tar.gz
musl-c6383b7b10303457306932584fc23f24b5153a81.tar.xz
musl-c6383b7b10303457306932584fc23f24b5153a81.zip
math: use 0x1p-120f and 0x1p120f for tiny and huge values
previously 0x1p-1000 and 0x1p1000 was used for raising inexact
exception like x+tiny (when x is big) or x+huge (when x is small)

the rational is that these float consts are large enough
(0x1p-120 + 1 raises inexact even on ld128 which has 113 mant bits)
and float consts maybe smaller or easier to load on some platforms
(on i386 this reduced the object file size by 4bytes in some cases)
Diffstat (limited to 'src/math/atan2l.c')
-rw-r--r--src/math/atan2l.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/math/atan2l.c b/src/math/atan2l.c
index e86dbffb..7cb42c2f 100644
--- a/src/math/atan2l.c
+++ b/src/math/atan2l.c
@@ -52,39 +52,39 @@ long double atan2l(long double y, long double x)
 		switch(m) {
 		case 0:
 		case 1: return y;           /* atan(+-0,+anything)=+-0 */
-		case 2: return  2*pio2_hi+0x1p-1000; /* atan(+0,-anything) = pi */
-		case 3: return -2*pio2_hi-0x1p-1000; /* atan(-0,-anything) =-pi */
+		case 2: return  2*pio2_hi+0x1p-120f; /* atan(+0,-anything) = pi */
+		case 3: return -2*pio2_hi-0x1p-120f; /* atan(-0,-anything) =-pi */
 		}
 	}
 	/* when x = 0 */
 	if (exptx==0 && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
-		return expsigny < 0 ? -pio2_hi-0x1p-1000 : pio2_hi+0x1p-1000;
+		return expsigny < 0 ? -pio2_hi-0x1p-120f : pio2_hi+0x1p-120f;
 	/* when x is INF */
 	if (exptx == 0x7fff) {
 		if (expty == 0x7fff) {
 			switch(m) {
-			case 0: return  pio2_hi*0.5+0x1p-1000; /* atan(+INF,+INF) */
-			case 1: return -pio2_hi*0.5-0x1p-1000; /* atan(-INF,+INF) */
-			case 2: return  1.5*pio2_hi+0x1p-1000; /* atan(+INF,-INF) */
-			case 3: return -1.5*pio2_hi-0x1p-1000; /* atan(-INF,-INF) */
+			case 0: return  pio2_hi*0.5+0x1p-120f; /* atan(+INF,+INF) */
+			case 1: return -pio2_hi*0.5-0x1p-120f; /* atan(-INF,+INF) */
+			case 2: return  1.5*pio2_hi+0x1p-120f; /* atan(+INF,-INF) */
+			case 3: return -1.5*pio2_hi-0x1p-120f; /* atan(-INF,-INF) */
 			}
 		} else {
 			switch(m) {
 			case 0: return  0.0;        /* atan(+...,+INF) */
 			case 1: return -0.0;        /* atan(-...,+INF) */
-			case 2: return  2*pio2_hi+0x1p-1000; /* atan(+...,-INF) */
-			case 3: return -2*pio2_hi-0x1p-1000; /* atan(-...,-INF) */
+			case 2: return  2*pio2_hi+0x1p-120f; /* atan(+...,-INF) */
+			case 3: return -2*pio2_hi-0x1p-120f; /* atan(-...,-INF) */
 			}
 		}
 	}
 	/* when y is INF */
 	if (expty == 0x7fff)
-		return expsigny < 0 ? -pio2_hi-0x1p-1000 : pio2_hi+0x1p-1000;
+		return expsigny < 0 ? -pio2_hi-0x1p-120f : pio2_hi+0x1p-120f;
 
 	/* compute y/x */
 	k = expty-exptx;
 	if(k > LDBL_MANT_DIG+2) { /* |y/x| huge */
-		z = pio2_hi+0x1p-1000;
+		z = pio2_hi+0x1p-120f;
 		m &= 1;
 	} else if (expsignx < 0 && k < -LDBL_MANT_DIG-2) /* |y/x| tiny, x<0 */
 		z = 0.0;