in reply to Re^2: perl subtraction
in thread perl subtraction
I'm afraid that didn't work out as I expected. I multiplied the amounts by 100 to get the amounts in cents. But when I compare the two, my script is still telling me that they are not equal./p>
use warnings; use strict; my($amt1,$amt2,$mytot,$perltot,$diff); print "Enter amt1 : "; chomp($amt1 = <STDIN>); print "\nEnter amt2 : "; chomp($amt2 = <STDIN>); print "\nEnter the total : "; chomp($mytot = <STDIN>); $mytot = $mytot * 100; # convert to cents $perltot = ($amt1 * 100) + ($amt2 * 100); #convert to cents $diff = $perltot - $mytot; print "$mytot - $perltot = $diff\n
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: perl subtraction
by dsheroh (Monsignor) on Jan 10, 2010 at 11:25 UTC |