summaryrefslogtreecommitdiff
path: root/frac.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-01-22 22:30:52 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-01-22 22:30:52 +0000
commit031deac645662aea8a72a5ed0c0bf148e609e681 (patch)
tree07c68b885a0c39a228ca4b0f7f901a9117f85a9f /frac.c
parent039c1c0135bac8353d17020543fe8b27f3b1937e (diff)
downloadmpfr-031deac645662aea8a72a5ed0c0bf148e609e681.tar.gz
added several hard-coded tests (and fixed bugs found)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2644 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'frac.c')
-rw-r--r--frac.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/frac.c b/frac.c
index 45833ecbe..ff9a36b00 100644
--- a/frac.c
+++ b/frac.c
@@ -52,7 +52,7 @@ mpfr_frac (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
ue = MPFR_GET_EXP (u);
if (ue <= 0) /* |u| < 1 */
- return mpfr_set(r, u, rnd_mode);
+ return mpfr_set (r, u, rnd_mode);
uq = MPFR_PREC(u);
un = (uq - 1) / BITS_PER_MP_LIMB; /* index of most significant limb */
@@ -88,7 +88,7 @@ mpfr_frac (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
fq = uq - ue; /* number of bits of the fractional part of u */
t = fq > MPFR_PREC(r) ?
- (mpfr_init2(tmp, (un + 1) * BITS_PER_MP_LIMB), tmp) : r;
+ (mpfr_init2 (tmp, (un + 1) * BITS_PER_MP_LIMB), tmp) : r;
/* t has enough precision to contain the fractional part of u */
/* If we use a temporary variable, we take the non-significant bits
of u into account, because of the mpn_lshift below. */
@@ -103,8 +103,8 @@ mpfr_frac (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
tp = MPFR_MANT(t);
if (sh == 0)
MPN_COPY_DECR(tp + t0, up, un + 1);
- else
- tp[tn] = k | mpn_lshift(tp + t0, up, un, sh);
+ else /* warning: un may be 0 here */
+ tp[tn] = k | ((un) ? mpn_lshift (tp + t0, up, un, sh) : (mp_limb_t) 0);
if (t0 > 0)
MPN_ZERO(tp, t0);
@@ -112,8 +112,8 @@ mpfr_frac (mpfr_ptr r, mpfr_srcptr u, mp_rnd_t rnd_mode)
{ /* t is tmp */
int inex;
- inex = mpfr_set(r, t, rnd_mode);
- mpfr_clear(t);
+ inex = mpfr_set (r, t, rnd_mode);
+ mpfr_clear (t);
return inex;
}
else