Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: log() and int() problem

by dave_the_m (Prior)
on Dec 25, 2012 at 18:34 UTC ( #1010282=note: print w/replies, xml ) Need Help??

in reply to Re: log() and int() problem
in thread log() and int() problem

And internally floats are stored in the string-slot of a variable
No they're not. An xpvnv has separate slots for an int, a float and a string:
[davem@pigeon bleed]$ p -MDevel::Peek -e'$x=1; $x=2.2; $x = "three"; D +ump $x' SV = PVNV(0x1ae3150) at 0x1b021d0 REFCNT = 1 FLAGS = (POK,pPOK) IV = 1 NV = 2.2 PV = 0x1afb360 "three"\0 CUR = 5 LEN = 16


Replies are listed 'Best First'.
Re^3: log() and int() problem
by LanX (Bishop) on Dec 25, 2012 at 18:49 UTC
    OK, thanks for correcting!

    (I already suspected that I should place one more "IIRC". :)

    Maybe I remembered something different or Scalar::Util::dualvar confused me or the reality in perl is even more complex. (and the latter wouldn't surprise me)

    Cheers Rolf

    PS: or was it JS ... ?!?


    For the records, here the source of my misunderstanding

    from perlnumber:

    Perl can internally represent numbers in 3 different ways: as native integers, as native floating point numbers, and as decimal strings. Decimal strings may have an exponential notation part, as in "12.34e-56" . Native here means "a format supported by the C compiler which was used to build perl".

    emphasis added.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010282]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2018-06-25 20:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (128 votes). Check out past polls.