Retrieve the logarithm of number in a specified base ?

Saverio Trioni saverio at mat.uab.es
Mon Dec 27 17:45:45 CET 2004


If you want to get just the *integer* part of the logarithm of an 
*integer* over an *integer* base, maybe it is better to recursively 
divide, using just mpz integer functions.

Sketch of the idea
(assuming number is greater than base)
(and using standard notation, to be readable)

mpz_t number, base;
long exponent=0;
while (number>base)
{
	exponent++;
	number/=base;
}
return exponent;


The actual function to perform de division should be (i think) 
mpz_tdiv_q(number,number,base)


I hope you get the idea.


More information about the gmp-discuss mailing list