logrithm
Décio Luiz Gazzoni Filho
decio at decpp.net
Mon Jul 25 07:25:59 CEST 2005
On Jul 25, 2005, at 1:01 AM, hatem Ibrahim wrote:
> Dear all
>
> I will be thankfull if someone iform me how to
> calculate logarithm to base 2.
> ( Is there any function to compute the log for mpz_t
> number? )
If you just want to count the number of bits (i.e. the ceiling of the
base-2 logarithm), then use the function mpz_sizeinbase(value,2).
This call is almost free, as far as I know. Now if you want the
floating-point value of the logarithm to a desired number of places
(a costly call as it involves series computation), then GMP doesn't
compute this -- you'll have to use MPFR as the other poster pointed out.
Décio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://gmplib.org/list-archives/gmp-discuss/attachments/20050725/c6ee13a7/PGP.bin
More information about the gmp-discuss
mailing list