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

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

Thread Next
From:
Dan Book
Date:
June 27, 2019 14:35
Subject:
[perl #134230] Numifying a 0x string evaluates the hex number
Message ID:
rt-4.0.24-15704-1561646145-1494.134230-75-0@perl.org
# 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 Next


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