From 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 12 Feb 2011 00:22:29 -0500 Subject: initial check-in, version 0.5.0 --- src/stdlib/frexpl.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/stdlib/frexpl.c (limited to 'src/stdlib/frexpl.c') diff --git a/src/stdlib/frexpl.c b/src/stdlib/frexpl.c new file mode 100644 index 00000000..ecfff007 --- /dev/null +++ b/src/stdlib/frexpl.c @@ -0,0 +1,25 @@ +#include +#include + +/* This version is for 80-bit little endian long double */ + +long double frexpl(long double x, int *e) +{ + union { long double ld; uint16_t hw[5]; } y = { x }; + int ee = y.hw[4]&0x7fff; + + if (!ee) { + if (x) { + x = frexpl(x*0x1p64, e); + *e -= 64; + } else *e = 0; + return x; + } else if (ee == 0x7fff) { + return x; + } + + *e = ee - 0x3ffe; + y.hw[4] &= 0x8000; + y.hw[4] |= 0x3ffe; + return y.ld; +} -- cgit v1.2.1