aboutsummaryrefslogtreecommitdiff
path: root/py/mpz.c
diff options
context:
space:
mode:
authorDavid Steinberg <david.steinberg.dev@gmail.com>2015-01-13 15:20:32 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-24 20:54:28 +0000
commit8d427b7ab79d1d45d6aef2f0bbb73c65373247df (patch)
tree4cda22d9d95a436a5eca4c08569e16f19870311c /py/mpz.c
parentc585ad1020cf81cb277ecce77952f9c896ba7bbc (diff)
py: Fix issue in mpz_set_from_float() when mp_int_t is larger than float
Diffstat (limited to 'py/mpz.c')
-rw-r--r--py/mpz.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/mpz.c b/py/mpz.c
index 47cbf5db4..c0a3d4b0b 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -747,10 +747,16 @@ typedef uint32_t mp_float_int_t;
z->dig[dig_ind++] = (frc << shft) & DIG_MASK;
frc >>= DIG_SIZE - shft;
}
+#if DIG_SIZE < (MP_FLOAT_FRAC_BITS + 1)
while (dig_ind != dig_cnt) {
z->dig[dig_ind++] = frc & DIG_MASK;
frc >>= DIG_SIZE;
}
+#else
+ if (dig_ind != dig_cnt) {
+ z->dig[dig_ind] = frc;
+ }
+#endif
}
}
}