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

Re: [perl #132908] String/Number interpretation of a string

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
February 26, 2018 14:10
Subject:
Re: [perl #132908] String/Number interpretation of a string
Message ID:
20180226150952.54478ea3@pc09.procura.nl
On Sun, 25 Feb 2018 10:25:19 -0800, "perl@ton.iguana.be (via RT)"
<perlbug-followup@perl.org> wrote:

> perl -wlE '$_="-4-5"; say -$_|0'
> Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1.
> 4
> 
> perl -wlE '$_=-4 . -5; say -$_|0'
> Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1.
> 4
> 
> perl -wlE '$_="-4-5"; $_+0; say -$_|0'
> Useless use of addition (+) in void context at -e line 1.
> Argument "-4-5" isn't numeric in addition (+) at -e line 1.
> Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1.
> 4
> 
> perl -wlE '$_=-4 . -5; $_+0; say -$_|0'
> Useless use of addition (+) in void context at -e line 1.
> Argument "-4-5" isn't numeric in addition (+) at -e line 1.
> 18446744073709551612
> 
> That last one is very unexpected.
> The same thing happens on perl 5.26.1

Step-by-step on the last one ...

$ perl -MDP -wE'$_ = -4 . -5;DDump$_;$_+0;DDump$_;say $_|0;DDump$_'
Useless use of addition (+) in void context at -e line 1.
SV = PV(0x24679f0) at 0x24b0ab0
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x24839f0 "-4-5"\0
  CUR = 4
  LEN = 10
Argument "-4-5" isn't numeric in addition (+) at -e line 1.
SV = PVNV(0x370b100) at 0x24b0ab0
  REFCNT = 1
  FLAGS = (POK,pIOK,pNOK,pPOK)
  IV = -4
  NV = -4
  PV = 0x24839f0 "-4-5"\0
  CUR = 4
  LEN = 10
18446744073709551612
SV = PVNV(0x370b100) at 0x24b0ab0
  REFCNT = 1
  FLAGS = (POK,pIOK,pNOK,pPOK)
  IV = -4
  NV = -4
  PV = 0x24839f0 "-4-5"\0
  CUR = 4
  LEN = 10


-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.27   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