about summary refs log tree commit diff
path: root/src/math/frexpl.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-09-04 15:54:02 +0000
committerSzabolcs Nagy <nsz@port70.net>2013-09-05 11:30:08 +0000
commitaa0c4a204e28cfc90a9ee955691a6cbe014c9fde (patch)
treee75c43e934d087e203dc999ba75168ee78e6ee7b /src/math/frexpl.c
parent2eaed464e2080d8321d3903b71086a1ecfc4ee4a (diff)
downloadmusl-aa0c4a204e28cfc90a9ee955691a6cbe014c9fde.tar.gz
musl-aa0c4a204e28cfc90a9ee955691a6cbe014c9fde.tar.xz
musl-aa0c4a204e28cfc90a9ee955691a6cbe014c9fde.zip
math: long double fix (use ldshape union)
* use new ldshape union consistently
* add ld128 support to frexpl
* simplify sqrtl comment (ld64 is not just arm)
Diffstat (limited to 'src/math/frexpl.c')
-rw-r--r--src/math/frexpl.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/src/math/frexpl.c b/src/math/frexpl.c
index f9d90a6d..3c1b5537 100644
--- a/src/math/frexpl.c
+++ b/src/math/frexpl.c
@@ -1,20 +1,20 @@
-#include <math.h>
-#include <stdint.h>
-#include <float.h>
-
-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-
-/* This version is for 80-bit little endian long double */
+#include "libm.h"
 
+#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double frexpl(long double x, int *e)
 {
-	union { long double ld; uint16_t hw[5]; } y = { x };
-	int ee = y.hw[4]&0x7fff;
+	return frexp(x, e);
+}
+#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+long double frexpl(long double x, int *e)
+{
+	union ldshape u = {x};
+	int ee = u.i.se & 0x7fff;
 
 	if (!ee) {
 		if (x) {
-			x = frexpl(x*0x1p64, e);
-			*e -= 64;
+			x = frexpl(x*0x1p120, e);
+			*e -= 120;
 		} else *e = 0;
 		return x;
 	} else if (ee == 0x7fff) {
@@ -22,16 +22,8 @@ long double frexpl(long double x, int *e)
 	}
 
 	*e = ee - 0x3ffe;
-	y.hw[4] &= 0x8000;
-	y.hw[4] |= 0x3ffe;
-	return y.ld;
+	u.i.se &= 0x8000;
+	u.i.se |= 0x3ffe;
+	return u.f;
 }
-
-#else
-
-long double frexpl(long double x, int *e)
-{
-	return frexp(x, e);
-}
-
 #endif