develooper Front page | perl.perl5.porters | Postings from November 2000

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
November 14, 2000 03:46
Subject:
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
20001114114631.E17040@plum.flirble.org
I substituted my UV+UV and IV+IV code for your 4 case test, letting the
IV/UV mix drop into the NV code.

numconvert.t starts to make sense. This and only 3 others fail:

./perl -MDevel::Peek -wle '$in = "4294967296"; print $in; $zero = 0; $in+=$zero; {use integer; $in + $zero;} $in+=$zero; print $in; Dump ($in)'
Useless use of integer addition (+) in void context at -e line 1.
4294967296
4294967295
SV = PVNV(0x8103f78) at 0x810b47c
  REFCNT = 1
  FLAGS = (IOK,POK,pIOK,pPOK,IsUV)
  UV = 4294967295
  NV = 4294967296
  PV = 0x810e6f8 "4294967295"\0
  CUR = 10
  LEN = 11


whereas real perl [NV perl :-)]

perl -MDevel::Peek -wle '$in = "4294967296"; print $in; $zero = 0; $in+=$zero; {use integer; $in + $zero;} print $in; Dump ($in)'
Useless use of integer addition (+) in void context at -e line 1.
4294967296
4294967296
SV = PVNV(0x81036d8) at 0x810abcc
  REFCNT = 1
  FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK,IsUV)
  UV = 4294967295
  NV = 4294967296
  PV = 0x8114270 "4294967296"\0
  CUR = 10
  LEN = 35


Is it because this piece of line noise:

PP(pp_i_add)
{
    djSP; dATARGET; tryAMAGICbin(add,opASSIGN);
    {
      dPOPTOPiirl_ul;
      SETi( left + right );
      RETURN;
    }
}

is setting public IOK flags?
[and having a nasty side effect on the public value of "left" and "right"
which contradicts man integer:

       Note that this affects the operations, not the numbers.
       If you run this code

           use integer;
           $x = 1.5;
           $y = $x + 1;
           $z = -1.5;

       you'll be left with "$x == 1.5", "$y == 2" and "$z == -1".
       The $z case happens because unary "-" counts as an
       operation.
]

hmm. this is installed DEVEL7414 and it looks wrong:

perl -MDevel::Peek -wle '$in = "4294967296"; print $in; $zero = 0; $in+=$zero; {use integer; $in + $zero;} Dump ($in)'
Useless use of integer addition (+) in void context at -e line 1.
4294967296
SV = PVNV(0x81036d8) at 0x810abc4
  REFCNT = 1
  FLAGS = (IOK,NOK,pIOK,pNOK,IsUV)
  UV = 4294967295
  NV = 4294967296
  PV = 0x8103008 "4294967296"\0
  CUR = 10
  LEN = 11


How can I have a scalar with both NOK and IOK, yet differing values in UV and
NV ? That's inconsistent.

Nick

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