summaryrefslogtreecommitdiff
path: root/insert-dbl.c
diff options
context:
space:
mode:
authortege <tege@gmplib.org>1999-02-22 22:10:34 +0100
committertege <tege@gmplib.org>1999-02-22 22:10:34 +0100
commitd90cdb57c73be00d56fa74de6a76519a8b323423 (patch)
tree6d0eaa22d7770fc632f1cd728677da988255cc1a /insert-dbl.c
parenta946bbea9e94a36dd719a3f6fc79a32135fa51ee (diff)
downloadgmp-d90cdb57c73be00d56fa74de6a76519a8b323423.tar.gz
Special case biased exponents < 1; Get boundary for Inf right
Diffstat (limited to 'insert-dbl.c')
-rw-r--r--insert-dbl.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/insert-dbl.c b/insert-dbl.c
index c63eaa557..02e8a6b65 100644
--- a/insert-dbl.c
+++ b/insert-dbl.c
@@ -45,11 +45,23 @@ __gmp_scale2 (d, exp)
x.d = d;
exp += x.s.exp;
x.s.exp = exp;
- if (exp >= 2048)
+ if (exp >= 2047)
{
+ /* Return +-infinity */
x.s.exp = 2047;
x.s.manl = x.s.manh = 0;
}
+ else if (exp < 1)
+ {
+ x.s.exp = 1; /* smallest exponent (biased) */
+ /* Divide result by 2 until we have scaled it to the right IEEE
+ denormalized number, but stop if it becomes zero. */
+ while (exp < 1 && x.d != 0)
+ {
+ x.d *= 0.5;
+ exp++;
+ }
+ }
return x.d;
}
#else