develooper Front page | perl.perl5.porters | Postings from October 2018

Re: [perl #133582] POSIX::log2 weird behaviour

Thread Previous | Thread Next
From:
James E Keenan
Date:
October 13, 2018 12:04
Subject:
Re: [perl #133582] POSIX::log2 weird behaviour
Message ID:
20181013120452.22489.qmail@lists-nntp.develooper.com
On 10/13/2018 12:05 AM, Tomasz Konojacki wrote:
> On Fri, 12 Oct 2018 19:10:52 -0700
> "James E Keenan via RT" <perlbug-followup@perl.org> wrote:
> 
>> Using perl-5.28.0 on Ubuntu Linux 18.04 LTS, I cannot reproduce your result:
>>
>> #####
>> $ perl -MPOSIX -e 'print POSIX::log2(64), "\n";'
>> 6
>> $ perl -MPOSIX -e 'print int POSIX::log2(64), "\n";'
>> 6
>> #####
>>
>> Same results on FreeBSD-11.1.
>>
>> Thank you very much.
>>
>> -- 
>> James E Keenan (jkeenan@cpan.org)
> 
> It's reproductible on windows:
> 
> C:\Users\xenu>perl -MPOSIX -e "print int POSIX::log2(64);"
> 5
> C:\Users\xenu>perl -MPOSIX -e "print POSIX::log2(64);"
> 6
> C:\Users\xenu>perl -MPOSIX -e "printf '%.30f', POSIX::log2(64);"
> 5.999999999999999111821580299875
> 
> It's caused by the fact our windows build system (config.gc and friends)
> doesn't know that MinGW and MSVC (since 2013) have C99 math functions
> like log2(), which causes POSIX.pm to emulate them instead of using the
> real thing.
> 
> I'll prepare a patch soon if no one beats me to it.
> 

That will be helpful; please include the sample as a test.  If there are 
other POSIX functions with similar behavior, please test them as well.

Thank you very much.
Jim Keenan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About