Little problem with rounding of totals. : 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 (, 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:


Greg Swofford

-- Gregory Swofford (, March 28, 2000.

Moderation questions? read the FAQ