summaryrefslogtreecommitdiff
path: root/mpf
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-05-17 10:06:48 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-05-17 10:06:48 +0200
commit33c963138adba26e8ff736fbc8296f3912eab5ac (patch)
tree099a7cec06a4624ca0af60b28ae0f727bf3b3dfe /mpf
parentd19ff2aff1ef81874454a00c59ca6fcc8523800c (diff)
downloadgmp-33c963138adba26e8ff736fbc8296f3912eab5ac.tar.gz
mpf/pow_ui.c: Simplify.
Diffstat (limited to 'mpf')
-rw-r--r--mpf/pow_ui.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mpf/pow_ui.c b/mpf/pow_ui.c
index 5d029147e..34cc7b2e3 100644
--- a/mpf/pow_ui.c
+++ b/mpf/pow_ui.c
@@ -24,18 +24,18 @@ void
mpf_pow_ui (mpf_ptr r, mpf_srcptr b, unsigned long int e)
{
mpf_t b2;
- unsigned long int e2;
mpf_init2 (b2, mpf_get_prec (r));
mpf_set (b2, b);
- mpf_set_ui (r, 1);
if ((e & 1) != 0)
- mpf_set (r, b2);
- for (e2 = e >> 1; e2 != 0; e2 >>= 1)
+ mpf_set (r, b);
+ else
+ mpf_set_ui (r, 1);
+ while (e >>= 1)
{
mpf_mul (b2, b2, b2);
- if ((e2 & 1) != 0)
+ if ((e & 1) != 0)
mpf_mul (r, r, b2);
}