Trailing zeros missing after subtraction

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 27, 2011   (RSS)

Hi all,

Small math problem here...

I'm offering a 10% discount to certain members and also refunding a registration fee if required.

The 10% works fine and trailing zeros are always shown.

The problem is that if the result of the subtraction has a trailing zero, the trailing zero disappears.

Any thoughts?

Thanks,

Jerry Kornbluth

Here’s the code I’m using:

First I define a variable to calculate a 10% discount
<?php $price_a = number_format($record['1_hour_session_price']*.90,2); ?>
And one for the registration fee amount:
<?php $deposit_amount = number_format($common_informationRecord['deposit_amount'],2); ?>
Then if the registration fee needs to be refunded, I’m using:
<?PHP if ($CURRENT_USER['registration_fee_refund'] == 1): ?><?php echo $price_a - $deposit_amount ?><?php else: ?><?php echo $price_a ?><?PHP endif ?>
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [Jason] Trailing zeros missing after subtraction

Thanks,

I (erroneously) thought that it would be enough to include number_format in the defined variables.

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php