sarcastic6
Limp Gawd
- Joined
- Jun 11, 2001
- Messages
- 223
I'm trying to figure out why this isn't working.
Consider the following code:
It outputs this:
And yet if I do a round(2.325, 2) manually, I get the CORRECT value, 2.33. What is going on?
Consider the following code:
PHP:
$salesTaxAmount = $subtotal * ($salesTaxPercent / 100);
$salesTax = round($salesTaxAmount , 2);
echo "Sales tax amount (calculated) is: " . $salesTaxAmount . ", ";
echo "sales tax (rounded) is: " . $salesTax . ", ";
echo "\$salesTaxAmount is a " . gettype($salesTaxAmount) . ", ";
echo "\$salesTax is a " . gettype($salesTax);
It outputs this:
Code:
Sales tax amount (calculated) is: 2.325,
sales tax (rounded) is: 2.32,
$salesTaxAmount is a double,
$salesTax is a double
And yet if I do a round(2.325, 2) manually, I get the CORRECT value, 2.33. What is going on?