Bug #15162: (int) cast doesn't work properly
| From: | mik at x dot org dot pl | Date: | Tue, 22 Jan 2002 13:45:33 +0000 |
| Subject: | Bug #15162: (int) cast doesn't work properly | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-77765@lists.php.net to get a copy of this message | ||
From: mik@x.org.pl
Operating system: slackware linux (kernel 2.2.19)
PHP version: 4.1.1
PHP Bug Type: Math related
Bug description: (int) cast doesn't work properly
i'm writing a little internet shop in php.
i found really bad bug, which can make a lot of losses to somebody...
may be i'm using cast not good way, but i call this bug anyway.
consider this script:
<?
$price = 33.44;
echo "the price is: $price <BR>";
$price_dolars = floor($price);
echo "number of cents is: " . ($price - $price_dolars)*100 . "<BR>";
// we can see value of 44
echo "but as integer it would be: " . (int)(($price - $price_dolars)*100)
. "<BR>";
// but now it is 43
?>
--
Edit bug report at: http://bugs.php.net/?id=15162&edit=1