in reply to subtraction issue

> This should result in $finalamount = 0 but it results in 1.13686837721616e-013 can anyone tell me why this is?

you most likely have a calculation resulting in a fraction of 0.12 after the point which is 3/25 and 25=5^2 can't be coded without loss in a binary system.

Additionally Perl does some DWIM magic to hide minor errors, such that a printed 0.12 is not necessarily == 0.12 .

solution:

To calculate dollars "accurately" with 2 decimal places, you need
to calculate right from the beginning in cents as integers!

So just calculate with integers in the desired accuracy and shift the decimal point afterwards!

from Humans have too many fingers

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!