[bigint] (Natural logarithm of a BigUnsigned)

Matt McCutchen <matt at mattmccutchen.net>
Wed Jul 16 14:23:15 PDT 2008


On Sat, 2008-07-12 at 17:03 +0200, Erhard Henkes wrote: 
> I need to calculate the natural logarithm of a BigUnsigned. How can I 
> manage that? There seems to be no member function. Can I use getLenth() 
> or other functions?

You can approximate the natural logarithm from the leftmost bits of the
number.  Motivated by your email and a previous one, I just added a
BigUnsigned::bitLength() function to the development version of the
library at:

http://mattmccutchen.net/bigint/bigint.git/

With this version of the library, you can use the attached code to
approximate the natural logarithm.

I don't know of an easy way to get the logarithm to arbitrary precision,
if that's what you're looking for.

Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: natural-log.cc
Type: text/x-c++src
Size: 612 bytes
Desc: not available
URL: <http://mattmccutchen.net/mailman/archives/bigint/attachments/20080716/34485677/attachment.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://mattmccutchen.net/mailman/archives/bigint/attachments/20080716/34485677/attachment.pgp>


More information about the bigint mailing list