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

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
November 14, 2000 05:58
Subject:
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
20001114075758.B27286@chaos.wustl.edu
> 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.

The above works okay for me in bleedperl:

kosh:~/pp4/perl ; ./perl -Ilib -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(0x14003f0d8) at 0x140014608
  REFCNT = 1
  FLAGS = (IOK,NOK,pIOK,pNOK)
  IV = 4294967296
  NV = 4294967296
  PV = 0x140015880 "4294967296"\0
  CUR = 10
  LEN = 11
kosh:~/pp4/perl ; 

How does your string $in gets converted to the (wrong) UV?

Hang on...my IVs/UVs are 64-bit...

./perl -Ilib -MDevel::Peek -wle '$in = "18446744073709551616"; print $in; $zero = 0; $in+=$zero;{use integer; $in + $zero;} Dump ($in)'
Useless use of integer addition (+) in void context at -e line 1.
18446744073709551616
SV = PVNV(0x14003f0d8) at 0x140014608
  REFCNT = 1
  FLAGS = (IOK,NOK,pIOK,pNOK,IsUV)
  UV = 18446744073709551615
  NV = 1.84467440737096e+19
  PV = 0x140036308 "18446744073709551616"\0
  CUR = 20
  LEN = 21

Egads.  I have the same affliction.  Because 18446744073709551616
doesn't fit in 64-bit UVs and 4294967296 in 32-bit UVs, the IOK/isUV
flags definitely shouldn't be turned on.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

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