Re: PHP can't compare...
| From: | Rasmus Lerdorf | Date: | Thu, 06 Dec 2001 18:09:51 +0000 |
| Subject: | Re: PHP can't compare... | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-72769@lists.php.net to get a copy of this message | ||
> You are absolutely right, we have to do something about handling money better before anyone
> else
> notices that 0.7 plus 0.1 is not 0.8 with php! (I've already had an e-commerce user
> notice that
> their account balance is misquoted because 82 - 2 became 79 because of this).
If you are dealing with something as simple as money, do not use floating
point at all. Just multiply everything by 100 and deal only with
integers. That solves all your problems without any performance hit.
There is nothing to fix here.
-Rasmus