Skip Menu |

This queue is for tickets about the Math-Fortran CPAN distribution.

Report information
The Basics
Id: 133748
Status: open
Priority: 0/
Queue: Math-Fortran

People
Owner: Nobody in particular
Requestors: peter.john.acklam [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.03
Fixed in: (no value)



Subject: Improve accuracy of log10()
Currently, the implementation of log10() gives the following result: $ perl -MMath::Fortran=log10 -wle 'print int log10(1000)' 2 Here is a better implementation of log10() which ajusts the result to higher accuracy: sub log10 { my $x = shift; my $log_of_ten = log(10); my $y = log($x) / $log_of_ten; $y -= (10**$y - $x) / ($x * $log_of_ten); return $y; } The new implementation gives $ perl -MMath::Fortran=log10 -wle 'print int log10(1000)' 3
I wonder if this implementation should simply shift to calling POSIX::log10 instead, which directly binds to the C function of the same name?
On Mon Nov 16 13:33:53 2020, ETHER wrote: Show quoted text
> I wonder if this implementation should simply shift to calling > POSIX::log10 instead, which directly binds to the C function of > the same name?
Except for the overhead of loading the POSIX module, I see no disadvantages to this.