diff options
author | Steve Zesch <[email protected]> | 2012-11-24 20:54:47 -0500 |
---|---|---|
committer | Steve Zesch <[email protected]> | 2012-11-24 20:54:47 -0500 |
commit | 4531aea8ae8b2253218e0c6734618823003d2408 (patch) | |
tree | 3ce5bce7292f40350e6aef4831f75c5ab73b5c8c | |
parent | c95fe11de7b22818c8d8a9d2b80fdd91cbd8373f (diff) | |
download | mate-calc-4531aea8ae8b2253218e0c6734618823003d2408.tar.bz2 mate-calc-4531aea8ae8b2253218e0c6734618823003d2408.tar.xz |
Reapply shift fix from 7155e47
-rw-r--r-- | src/mp-binary.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mp-binary.c b/src/mp-binary.c index 4c8eafb..8836776 100644 --- a/src/mp-binary.c +++ b/src/mp-binary.c @@ -180,7 +180,10 @@ mp_mask(const MPNumber *x, int wordlen, MPNumber *z) void mp_shift(const MPNumber *x, int count, MPNumber *z) { - int i, multiplier = 1; + int i; + MPNumber multiplier; + + mp_set_from_integer(1, &multiplier); if (!mp_is_integer(x)) { /* Translators: Error displayed when bit shift attempted on non-integer values */ @@ -190,15 +193,14 @@ mp_shift(const MPNumber *x, int count, MPNumber *z) if (count >= 0) { for (i = 0; i < count; i++) - multiplier *= 2; - mp_multiply_integer(x, multiplier, z); + mp_multiply_integer(&multiplier, 2, &multiplier); + mp_multiply(x, &multiplier, z); } else { - MPNumber temp; for (i = 0; i < -count; i++) - multiplier *= 2; - mp_divide_integer(x, multiplier, &temp); - mp_floor(&temp, z); + mp_multiply_integer(&multiplier, 2, &multiplier); + mp_divide(x, &multiplier, z); + mp_floor(z, z); } } |