summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteve Zesch <[email protected]>2012-11-24 20:54:47 -0500
committerSteve Zesch <[email protected]>2012-11-24 20:54:47 -0500
commit4531aea8ae8b2253218e0c6734618823003d2408 (patch)
tree3ce5bce7292f40350e6aef4831f75c5ab73b5c8c /src
parentc95fe11de7b22818c8d8a9d2b80fdd91cbd8373f (diff)
downloadmate-calc-4531aea8ae8b2253218e0c6734618823003d2408.tar.bz2
mate-calc-4531aea8ae8b2253218e0c6734618823003d2408.tar.xz
Reapply shift fix from 7155e47
Diffstat (limited to 'src')
-rw-r--r--src/mp-binary.c16
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);
}
}