I am running a perl script and basic addition operators seem to be not working. For my code
print $total_charges," 1 \n";
print $payments," payments\n";
$total_charges+=$payments;
print $total_charges," 2 \n";
For this code, the output is the following
10192.19 1
-401.99 payments
9790.20000000005 2
If you do the math, this number would be correct except for the extra decimal places. What is going on?
I need these numbers to be accurate. Any suggestions on fixing this, or do I just truncate to 2 decimals each time?