Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: int() function

by tobyink (Canon)
on Oct 24, 2020 at 20:04 UTC ( [id://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 (Saint) 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>

    yep!

    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-25 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found