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

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

Thread Previous | Thread Next
From:
Tomasz Konojacki
Date:
October 13, 2018 04:13
Subject:
Re: [perl #133582] POSIX::log2 weird behaviour
Message ID:
20181013060539.F977.5C4F47F8@xenu.pl
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.

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