mpz_sizeinbase

Minh Nguyen md6nguyen@yahoo.com
Mon, 28 Oct 2002 12:17:37 -0800 (PST)


--0-1304335214-1035836257=:563
Content-Type: text/plain; charset=us-ascii


Hi, the document said the following about the function mpz_sizeinbase(mpz_t op, int base) "...The result will be exact or 1 too big..."

Now, suppose the return value of mpz_sizeinbase(op, base) is numdigs and I want to know the *exact* number of digits. The most straightforward way is to compare op with base^(numdigs-1) and then reduce numdigs by 1 if op is less than              base^(numdigs-1). Is there a better way?

By the way, is it too expensive to *always* return the exact number of digits when base is not 2 ? 

Thanks,

Minh

 



---------------------------------
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
--0-1304335214-1035836257=:563
Content-Type: text/html; charset=us-ascii

<P>Hi, the document said the following about the function mpz_sizeinbase(mpz_t op, int base) "...The result will be exact or 1 too big..."</P>
<P>Now, suppose the return value of mpz_sizeinbase(op, base) is numdigs and I want to know the *exact* number of digits. The most straightforward way is to compare op with base^(numdigs-1) and then reduce numdigs by 1 if op is less than&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base^(numdigs-1). Is there a better way?</P>
<P>By the way, is it too expensive to *always* return the exact number of digits when base is not 2 ? </P>
<P>Thanks,</P>
<P>Minh</P>
<P>&nbsp;</P><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://webhosting.yahoo.com/ ">Y! Web Hosting</a> - Let the expert host your web site
--0-1304335214-1035836257=:563--