note 34851 deleted from language.types.string by didou
| From: | didou@php.net | Date: | Fri, 08 Aug 2003 15:05:57 +0000 |
| Subject: | note 34851 deleted from language.types.string by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53653@lists.php.net to get a copy of this message | ||
Note Submitter: php %at_ cybercow dot se
----
Do you think this is strange? Me too! Any explanation, anybody?
$basePrice = 600*0.82;
// will be 492
echo $basePrice;
// will be 491
echo (int)$basePrice;
This will fix the problem.
$basePrice = round(600*0.82);
// will be 492
echo $basePrice;
// will be 492
echo (int)$basePrice;
Strange doubles, we get the same error in c
double basePrice = 600;
// basePrice = 492.00000000000
basePrice = basePrice*0.82;
// nBasePrice = 491
int nBasePrice = (int)basePrice;