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 06:10
Subject:
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
20001114141030.A87735@plum.flirble.org
On Tue, Nov 14, 2000 at 07:57:58AM -0600, Jarkko Hietaniemi wrote:
> ./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.

It's the same as

perl -MDevel::Peek -wle '$in = "3.1"; 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.
3.1
3.1
SV = PVNV(0x81036d8) at 0x810abb8
  REFCNT = 1
  FLAGS = (IOK,NOK,POK,pIOK,pNOK,pPOK)
  IV = 3
  NV = 3.1
  PV = 0x8109ab0 "3.1"\0
  CUR = 3
  LEN = 35


the IV slot holds the accurate integer representation of the NV, but
the IV has lost precision.

is the cast (IV) expensive?
If it is, then it would make sense to flag in some way that IV slot is valid,
  but NV preferred (so that polymorphic operators know what to do)
  [not the current flags which are saying that the two are equivalent and
   equally valid]
If not, then I see no point storing anything.

Nicholas Clark

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