diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-09-30 09:21:11 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-09-30 09:21:11 +0000 |
commit | 5ad2c73eefbefc7840095a6bafb14776ad3ae2fe (patch) | |
tree | 855cbad13690656da40c25a30efd5cd11ccb9c66 | |
parent | b2b713868a0c48adcc5137eed3b40b371ee1bad1 (diff) | |
download | mpfr-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.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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))); } } } |