Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: int() function

by geoperl (Novice)
on Oct 24, 2020 at 22:28 UTC ( [id://11123140]=note: print w/replies, xml ) Need Help??


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

Thank you Rob

You are right. In my first example (1.15*170)+.5 the 15th decinal digit is 4 so it rounds to 195, whereas in my second example (1.15*150)+.5 the 15th decinal digit is 6 so it rounds to 173.

The 1.15 is actually 15% (selectable by user) on top of a price. So the script calculates (1+ 15/100)*price and because the final price must be rounded to the nearest integer, I added 0.50

I wanted to avoid loading Math::Round for just one calculation.

Replies are listed 'Best First'.
Re^3: int() function
by LanX (Saint) on Oct 24, 2020 at 23:25 UTC
    > I wanted to avoid loading Math::Round for just one calculation.

    Did you see my reply?

    Especially the last part titled "workaround"? ;)

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

      Yes, I saw it and I followed it

      Thank you so much Rolf

Log In?
Username:
Password:

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

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

    No recent polls found