note 34851 added to language.types.string
| From: | php at rack1 dot php dot net | Date: | Fri, 08 Aug 2003 14:16:35 +0000 |
| Subject: | note 34851 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53648@lists.php.net to get a copy of this message | ||
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;
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34851
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34851&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34851&report=yes