Little problem with rounding of totals.greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread
In general Barry's script works ok, but today I noticed that the rounding (sub Round) is implemented when calculating the results (in 'review' and 'buy' modes). What I've done is tried to exclude all the Round() call's from the script body, but seems like it doesn't works.
Is there anyone who had such a problem? Maybe there is something with Pad() subroutine, but I can't figure it. Please, help!
Thanks in advance.
-- Pavel Lukin (email@example.com), March 28, 2000
In the early days, there was some risk in using sprintf. No more fear and barry's rounding is overkill. For smart store, we are really not rounding, but formatting which has IMPLICIT rounding by Perl itself. So anytime you encounter a variable that needs 'rounding' skip the subroutine and use sprintf as:
$shipamt = $totalweight * $shiprate; $shipamt = sprintf ('%.2f',$shipamt);
Once more, ALL these problems have been solved in the new scripts. New scripts are available:
HOST-HERE DOWNLOAD ENGINE http://host-here.com/cgi-local/download/downloader.cgi
-- Gregory Swofford (firstname.lastname@example.org), March 28, 2000.