summaryrefslogtreecommitdiff
path: root/set_d.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-16 09:55:46 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-16 09:55:46 +0000
commit7f857964d869e4a3f316a7da845e11a9da0388a5 (patch)
treec6324c9251f6d5080b8927e6121b27c64fb5f708 /set_d.c
parent9ff0c4e04d3d5ef8057cb3c0b70e28938e5fa882 (diff)
downloadmpfr-7f857964d869e4a3f316a7da845e11a9da0388a5.tar.gz
Fixed several bugs.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2502 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_d.c')
-rw-r--r--set_d.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/set_d.c b/set_d.c
index a98256d3c..a6fa6bf42 100644
--- a/set_d.c
+++ b/set_d.c
@@ -30,12 +30,10 @@ MA 02111-1307, USA. */
#define MPFR_LIMBS_PER_DOUBLE 2
#elif (BITS_PER_MP_LIMB >= 64)
#define MPFR_LIMBS_PER_DOUBLE 1
-#elif (BITS_PER_MP_LIMB == 16)
-#define MPFR_LIMBS_PER_DOUBLE 4
+#else
+#error "Unsupported value of BITS_PER_MP_LIMB"
#endif
-static int __mpfr_extract_double _PROTO ((mp_ptr, double));
-
/* Included from gmp-2.0.2, patched to support denorms */
#ifdef XDEBUG
@@ -57,10 +55,9 @@ __mpfr_extract_double (mp_ptr rp, double d)
#endif
/* BUGS
-
1. Should handle Inf and NaN in IEEE specific code.
2. Handle Inf and NaN also in default code, to avoid hangs.
- 3. Generalize to handle all BITS_PER_MP_LIMB >= 32.
+ 3. Generalize to handle all BITS_PER_MP_LIMB.
4. This lits is incomplete and misspelled.
*/
@@ -71,6 +68,7 @@ __mpfr_extract_double (mp_ptr rp, double d)
}
#if _GMP_IEEE_FLOATS
+
{
union ieee_double_extract x;
x.d = d;
@@ -96,16 +94,21 @@ __mpfr_extract_double (mp_ptr rp, double d)
manl = x.s.manl << 11; /* low 21 bits */
#endif
}
+
+ if (exp)
+ exp -= 1022;
+ else
+ exp = -1021;
}
-#else
+
+#else /* _GMP_IEEE_FLOATS */
+
{
/* Unknown (or known to be non-IEEE) double format. */
exp = 0;
if (d >= 1.0)
{
- if (d * 0.5 == d)
- abort ();
-
+ MPFR_ASSERTN (d * 0.5 != d);
while (d >= 32768.0)
{
d *= (1.0 / 65536.0);
@@ -138,12 +141,9 @@ __mpfr_extract_double (mp_ptr rp, double d)
manh = d;
manl = (d - manh) * MP_BASE_AS_DOUBLE;
#endif
-
- exp += 1022;
}
-#endif
- if (exp) exp = (unsigned) exp - 1022; else exp = -1021;
+#endif /* _GMP_IEEE_FLOATS */
#if BITS_PER_MP_LIMB == 64
rp[0] = manl;