diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-06-24 19:58:20 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2012-06-24 19:58:20 +0200 |
commit | ef34640f9edc108eb48d5cebe7ad08c7cd2ed945 (patch) | |
tree | 2861d63900a3c8ce35f737808a307273418a5d73 /gen-trialdivtab.c | |
parent | 099a412390e030f7fdfe6479c2a6794d6baf42a0 (diff) | |
download | gmp-ef34640f9edc108eb48d5cebe7ad08c7cd2ed945.tar.gz |
gen-trialdivtab.c (mpz_log2): Use mpz_sizeinbase (., 2)
Diffstat (limited to 'gen-trialdivtab.c')
-rw-r--r-- | gen-trialdivtab.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/gen-trialdivtab.c b/gen-trialdivtab.c index 095166473..d87265ec4 100644 --- a/gen-trialdivtab.c +++ b/gen-trialdivtab.c @@ -2,7 +2,7 @@ Contributed to the GNU project by Torbjorn Granlund. -Copyright 2009 Free Software Foundation, Inc. +Copyright 2009, 2012 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -203,20 +203,7 @@ main (int argc, char *argv[]) unsigned long mpz_log2 (mpz_t x) { - mpz_t y; - unsigned long cnt; - - mpz_init (y); - mpz_set (y, x); - cnt = 0; - while (mpz_sgn (y) != 0) - { - mpz_tdiv_q_2exp (y, y, 1); - cnt++; - } - mpz_clear (y); - - return cnt; + return mpz_sgn (x) ? mpz_sizeinbase (x, 2) : 0; } void |