use bugnum; say log(0.5);
Hmm .. I suppose you want Math::BigNum and not the unknown bugnum module.
And .. after that, this module does have log functions ..
The log functions are called blog.... $x->blog(); # logarithm of $x to base e (Euler's number) $x->blog($base); # logarithm of $x to base $base (e.g., base 2) $x->bexp(); # calculate e ** $x where e is Euler's number $x->bilog2(); # log2($x) rounded down to nearest int $x->bilog10(); # log10($x) rounded down to nearest int $x->bclog2(); # log2($x) rounded up to nearest int $x->bclog10(); # log19($x) rounded up to nearest int ...
If I run this ..
.. I get a good value. That presumably uses Perl's built in log function.tab@music4:~/Pianoforte/Perlmonks 21:54:45 $ cat !$ cat 11156670.pl #!/usr/bin/perl use strict; use warnings; # use Math::BigNum; { print "Log of .5 is " . log(0.5) . "\n"; } tab@music4:~/Pianoforte/Perlmonks 21:54:51 $ ./11156670.pl Log of .5 is -0.693147180559945 tab@music4:~/Pianoforte/Perlmonks 21:54:57 $
I can strongly recommend a complete, self-contained example that shows the output .. this will help you solve things faster.
In reply to Re: log(0.5) with bignum blows up
by talexb
in thread log(0.5) with bignum blows up
by jimav
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |