Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: int() function

by tobyink (Canon)
on Oct 24, 2020 at 20:04 UTC ( #11123131=note: print w/replies, xml ) Need Help??

in reply to Re: int() function
in thread int() function

Minor correction: in OP's code, it's not Perl's print() function that is rounding the floating point value up to 196. It's happening on string interpolation.

Replies are listed 'Best First'.
Re^3: int() function
by LanX (Cardinal) on Oct 24, 2020 at 20:36 UTC
    I think it's anything which does a stringification.

    DB<137> $x1 = (1.15*170)+0.50; DB<138> p "$x1" 196 DB<139> p $x1 196 DB<140> printf "%.20f\n",$x1 195.99999999999997000000 DB<141> $str = $x1."" DB<142> p length $str 3 DB<143>


    DB<151> $x2 = (1.15*170)+0.50; DB<152> Dump $x2 SV = NV(0x32cc698) at 0x32cc6b0 REFCNT = 1 FLAGS = (NOK,pNOK) NV = 196 DB<153> p $x2 196 DB<154> Dump $x2 SV = PVNV(0x1cb938) at 0x32cc6b0 REFCNT = 1 FLAGS = (NOK,pNOK) IV = 0 NV = 196 PV = 0x31a4748 "196"\0 CUR = 3 LEN = 32

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11123131]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2021-04-22 15:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found