summaryrefslogtreecommitdiff
path: root/set_f.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2004-02-18 10:41:00 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2004-02-18 10:41:00 +0000
commit9aaa91d7bcfb3165ebf1b25d734fd4a53a09506b (patch)
tree68a0f23f592adf1091e8df522c671d8e1a285029 /set_f.c
parente0c173aa446074d17178356b315fe870631f158d (diff)
downloadmpfr-9aaa91d7bcfb3165ebf1b25d734fd4a53a09506b.tar.gz
Fixed a bug in mpfr_set_f for 0 (wrong sign) and added the test.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2761 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_f.c')
-rw-r--r--set_f.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/set_f.c b/set_f.c
index a08f89072..17f01e794 100644
--- a/set_f.c
+++ b/set_f.c
@@ -31,22 +31,25 @@ mpfr_set_f (mpfr_ptr y, mpf_srcptr x, mp_rnd_t rnd_mode)
int inexact, carry = 0;
TMP_DECL(marker);
+ sx = ABS(SIZ(x)); /* number of limbs of the mantissa of x */
+
+ if (sx == 0) /* x is zero */
+ {
+ MPFR_CLEAR_FLAGS (y);
+ MPFR_SET_ZERO(y);
+ MPFR_SET_POS(y);
+ return 0; /* 0 is exact */
+ }
+
if (SIZ(x) * MPFR_FROM_SIGN_TO_INT(MPFR_SIGN(y)) < 0)
MPFR_CHANGE_SIGN (y);
MPFR_CLEAR_FLAGS (y);
- sx = ABS(SIZ(x)); /* number of limbs of the mantissa of x */
sy = 1 + (MPFR_PREC(y) - 1) / BITS_PER_MP_LIMB;
my = MPFR_MANT(y);
mx = PTR(x);
- if (sx == 0) /* x is zero */
- {
- MPFR_SET_ZERO(y);
- return 0; /* 0 is exact */
- }
-
count_leading_zeros(cnt, mx[sx - 1]);
if (sy <= sx) /* we may have to round even when sy = sx */