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:
Eric Brine
Date:
June 28, 2019 05:34
Subject:
Re: [perl #134230] Numifying a 0x string evaluates the hex number
Message ID:
CALJW-qHPg80Ma0XwQmMeD7Q_0PMVxXWq+tfDY0D9PO8E5Jr=Bg@mail.gmail.com
Changing this means changing Scalar::Util::looks_like_number. Would that
break things?

Also, it could break things that use the regex patterns provided in
perldata to (effectively) recreate looks_like_number.

On Thu, Jun 27, 2019 at 10:35 AM Dan Book (via RT) <
perlbug-followup@perl.org> wrote:

> # New Ticket Created by  Dan Book
> # Please include the string:  [perl #134230]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org/Ticket/Display.html?id=134230 >
>
>
> When starting with a string that looks like '0xFF', numifying it should
> truncate it to 0 - consistent with 0b and 0 which only have an effect on
> bare number parsing. This behavior seems to have changed in 5.30.
>
> 5.28:
> > perl -Mwarnings -e 'print "0xFF" + 0, "\n"'
> Argument "0xFF" isn't numeric in addition (+) at -e line 1.
> 0
>
> 5.30:
> > perl -Mwarnings -e 'print "0xFF" + 0, "\n"'
> Argument "0xFF" isn't numeric in addition (+) at -e line 1.
> 255
>
> It also seems to have had this behavior way back in 5.6:
> > perl -Mwarnings -e 'print "0xFF" + 0, "\n"'
> Argument "0xFF" isn't numeric in addition (+) at -e line 1.
> 255
>
> -Dan
>
>

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