develooper Front page | perl.perl5.porters | Postings from June 2019

Re: [perl #134230] Numifying a 0x string evaluates the hex number

Thread Previous | Thread Next
From:
sisyphus
Date:
June 28, 2019 01:14
Subject:
Re: [perl #134230] Numifying a 0x string evaluates the hex number
Message ID:
CADZSBj0KCtenOdWciKRNH5u_fUZ2Zgez7vSbjueson0aPgTE6g@mail.gmail.com
I expect this will be due to commit
ce6f496d720f6206455628425320badd95b07372, with which RT 41202 was resolved.
With that commit, we can expect that expressions like "0xFF"+0 and
 "0b1001"+0 will numify to the same NV as POSIX::strtod("0xFF") and
POSIX::strtod("0b1001") respectively.
Is this a behaviour that should be changed ?

For me, strtod() does not understand the '0b' prefix and simply numifies
such strings to an NV of zero.

C:\>perl -MPOSIX -le "@x=POSIX::strtod('0b11111'); print for @x;"
0
6

But it does understand the '0x' prefix:

C:\>perl -MPOSIX -le "@x=POSIX::strtod('0xff'); print for @x;"
255
0

 Cheers,
Rob



On Fri, Jun 28, 2019 at 12:50 AM H.Merijn Brand <h.m.brand@xs4all.nl> wrote:

> On Thu, 27 Jun 2019 07:35:45 -0700, "Dan Book \(via RT\)"
> <perlbug-followup@perl.org> wrote:
>
> > perl -Mwarnings -e 'print "0xFF" + 0, "\n"'
>
> Interesting
>
> $ perl-all -le 'print "0xFF" + 0'
> Running perl-all -le print "0xFF" + 0
>
> === base/perl5.6.0      5.006    x86_64-linux
> 255
> === base/perl5.6.1      5.006001 x86_64-linux-perlio
> 255
> === base/tperl5.6.1     5.006001 x86_64-linux-thread-multi-ld-perlio
> 255
> === base/perl5.6.2      5.006002 x86_64-linux-perlio
> 255
> === base/tperl5.6.2     5.006002 x86_64-linux-thread-multi-ld-perlio
> 255
> === base/perl5.6        5.006002 x86_64-linux-perlio
> 255
> === base/tperl5.6       5.006002 x86_64-linux-thread-multi-ld-perlio
> 255
> === base/perl5.8.0      5.008    x86_64-linux
> 0
> === base/tperl5.8.0     5.008    x86_64-linux-thread-multi-ld
> 0
> === base/perl5.8.1      5.008001 x86_64-linux
> 0
> === base/tperl5.8.1     5.008001 x86_64-linux-thread-multi-ld
> 0
> === base/perl5.8.2      5.008002 x86_64-linux
> 0
>
> ... 0 all the way to
>
> === base/tperl5.28      5.028001 x86_64-linux-thread-multi-ld
> 0
> === base/perl5.29.0     5.029000 x86_64-linux
> 0
> === base/tperl5.29.0    5.029000 x86_64-linux-thread-multi-ld
> 0
> === base/perl5.29.1     5.029001 x86_64-linux
> 0
> === base/tperl5.29.1    5.029001 x86_64-linux-thread-multi-ld
> 0
> === base/perl5.29.2     5.029002 x86_64-linux
> 255
> === base/tperl5.29.2    5.029002 x86_64-linux-thread-multi-ld
> 255
> === base/perl5.29.3     5.029003 x86_64-linux
> 255
> === base/tperl5.29.3    5.029003 x86_64-linux-thread-multi-ld
> 255
> === base/perl5.29.4     5.029004 x86_64-linux
> 255
> === base/tperl5.29.4    5.029004 x86_64-linux-thread-multi-ld
> 255
> === base/perl5.29.5     5.029005 x86_64-linux
> 255
> === base/tperl5.29.5    5.029005 x86_64-linux-thread-multi-ld
> 255
> === base/perl5.29.6     5.029006 x86_64-linux
> 255
> === base/tperl5.29.6    5.029006 x86_64-linux-thread-multi-ld
> 255
> === base/perl5.29       5.029006 x86_64-linux
> 255
> === base/tperl5.29      5.029006 x86_64-linux-thread-multi-ld
> 255
>
> I have more perl's at home
>
> --
> H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
> using perl5.00307 .. 5.29   porting perl5 on HP-UX, AIX, and openSUSE
> http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
> http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/
>

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