summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2004-09-30 09:21:11 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2004-09-30 09:21:11 +0000
commit5ad2c73eefbefc7840095a6bafb14776ad3ae2fe (patch)
tree855cbad13690656da40c25a30efd5cd11ccb9c66
parentb2b713868a0c48adcc5137eed3b40b371ee1bad1 (diff)
downloadmpfr-5ad2c73eefbefc7840095a6bafb14776ad3ae2fe.tar.gz
The cast to uintmax_t wasn't really useful, so I removed it.
Added a comment. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3014 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--get_sj.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/get_sj.c b/get_sj.c
index 87269b7c0..0e06f08e3 100644
--- a/get_sj.c
+++ b/get_sj.c
@@ -94,9 +94,16 @@ mpfr_get_sj (mpfr_srcptr f, mpfr_rnd_t rnd)
for (n = MPFR_LIMB_SIZE (x) - 1; n >= 0; n--)
{
sh -= BITS_PER_MP_LIMB;
+ /* Note the concerning the casts below:
+ When sh >= 0, the cast must be performed before the shift
+ for the case sizeof(intmax_t) > sizeof(mp_limb_t).
+ When sh < 0, the cast must be performed after the shift
+ for the case sizeof(intmax_t) == sizeof(mp_limb_t), as
+ mp_limb_t is unsigned, therefore not representable as an
+ intmax_t when the MSB is 1 (this is the case here). */
r += (sh >= 0
? (intmax_t) xp[n] << sh
- : (intmax_t) ((uintmax_t) xp[n] >> (-sh)));
+ : (intmax_t) (xp[n] >> (-sh)));
}
}
else
@@ -104,9 +111,10 @@ mpfr_get_sj (mpfr_srcptr f, mpfr_rnd_t rnd)
for (n = MPFR_LIMB_SIZE (x) - 1; n >= 0; n--)
{
sh -= BITS_PER_MP_LIMB;
+ /* See above for the note concerning the casts. */
r -= (sh >= 0
? (intmax_t) xp[n] << sh
- : (intmax_t) ((uintmax_t) xp[n] >> (-sh)));
+ : (intmax_t) (xp[n] >> (-sh)));
}
}
}