in reply to Multiplication problem
I'm not sure how much freedom you have to refactor, but you might consider working with integers in pennies instead of floating points in dollars.
Also, while I know nothing of the larger context of your program, I'm not sure you need to round when multiplying an integer quantity (one assumption I'm making). Rounding would be more of a concern in division or multiplying two floats (do you have fractional quantities?).
Consider:
C:\chas_sandbox>perl -le "print +(int((17.95 *3)*100 )/ 100)" 53.84 C:\chas_sandbox>perl -le "print 17.95 *3" 53.85 C:\chas_sandbox>perl -le "print 1795 *3" 5385
Whatever the case, it's probably wise to follow dragonchild's advice and not fix what isn't broke.
|
|---|