summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-10-15 14:05:10 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-10-15 14:05:10 +0000
commit4e58d03990281323a19547f948f6ffc5020cacc9 (patch)
tree736c9653998220e298ad940dfd389dee93b96af0 /random.c
parenta747d09e4e9906e74a9cca6be65a4e73b4e21fb4 (diff)
downloadmpfr-4e58d03990281323a19547f948f6ffc5020cacc9.tar.gz
sign was not set
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1252 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'random.c')
-rw-r--r--random.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/random.c b/random.c
index 64532b629..425e66e8b 100644
--- a/random.c
+++ b/random.c
@@ -44,14 +44,18 @@ mpfr_random (x)
mpn_random (xp, xn);
- if (xp[xn - 1] == 0) xp[xn - 1] = 1;
+ if (xp[xn - 1] == 0)
+ xp[xn - 1] = 1;
/* since count_leading_zeros doesn't like zeroes */
count_leading_zeros (cnt, xp[xn - 1]);
- if (cnt) mpn_lshift (xp, xp, xn, cnt);
+ if (cnt)
+ mpn_lshift (xp, xp, xn, cnt);
MPFR_EXP(x) = -cnt;
+ if (MPFR_SIGN(x) < 0)
+ MPFR_CHANGE_SIGN(x);
- cnt = xn*BITS_PER_MP_LIMB - prec;
+ cnt = xn * BITS_PER_MP_LIMB - prec;
/* cnt is the number of non significant bits in the low limb */
xp[0] &= ~((((mp_limb_t) 1) << cnt) - 1);
}