2

According to the GMP documentation here:

Function: unsigned long int mpz_remove (mpz_t rop, mpz_t op, mpz_t f)

Remove all occurrences of the factor f from op and store the result in rop. The return value is how many such occurrences were removed.

So the mpz_remove function should be able to be used to answer the titled question. At the moment my code looks like this:

  mpz_set_ui(temp2,2);
  mpz_remove(temp,K0,temp2);

which works fine, but the result I want is K0 divided by temp (and not temp itself) [which I could get by adding a subsequent division operation, but that seems wasteful].

How should I actually get K0/temp?

4

1 回答 1

1

您可以尝试 mpz_scan1() 和 mpz_tdiv_q_2exp() 的组合。

mpz_tdiv_q_2exp(result,K0,mpz_scan1(K0,0))
于 2010-10-27T05:19:51.193 回答