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