Skip Menu |

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

Report information
The Basics
Id: 133749
Status: rejected
Priority: 0/
Queue: Math-Utils

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

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



Subject: Improve accuracy of log10()
Currently, the implementation of log10() gives the following result: $ perl -MMath::Utils=log10 -wle 'print int log10(1000)' 2 Here is a better implementation of log10() which adjusts the intermediate result to higher accuracy: sub log10 { my @y = (); my $log10 = log(10); for my $x (@_) { my $y = log($x) / $log10; $y -= (10**$y - $x) / ($x * $log10); push @y, $y; } return @y if wantarray; return $y[0]; } The new implementation gives $ perl -MMath::Utils=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:44 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?
As with CPAN RT #133748: Except for the overhead of loading the POSIX module, I see no disadvantages to this.
On Tue Nov 17 03:31:17 2020, pjacklam wrote: Show quoted text
> On Mon Nov 16 13:33:44 2020, ETHER wrote:
> > I wonder if this implementation should simply shift to calling > > POSIX::log10 instead, which directly binds to the C function of > > the same name?
> > As with CPAN RT #133748: Except for the overhead of loading the > POSIX module, I see no disadvantages to this.
I'm not going to do that, for two reasons: first, there's no point in linking to an already-existing function -- if the user wants to use the POSIX version of the function, then they should use the POSIX module. Second, there's better logarithm code out there that merely requires me to write an XS file. This is stalled due to the fact that I don't have a working Linux machine right now, and I haven't coded in C on Windows for a quarter of a century. We can discuss this further on the Github repository for this module if you like. It's my fault for not updating the CONTRIBUTING file, but I am not going to communicate via RT anymore (except for notices like this). Thanks.
Only technically rejected, see my earlier comment. Please post on Github.