Bug #2835 Updated: floor (8.28 * 100) = 8.27
| From: | Bug Database | Date: | Fri, 26 Nov 1999 17:46:04 +0000 |
| Subject: | Bug #2835 Updated: floor (8.28 * 100) = 8.27 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-13148@lists.php.net to get a copy of this message | ||
ID: 2835
User Update by: aulbach@unter.franken.de
Status: Closed
Bug Type: Misbehaving function
Description: floor (8.28 * 100) = 8.27
There are some things which I will say to this good
explanation:
1. This was of course clear for me, why this happens.
But, sorry, Ramus, I'm not sharing your opinion, that
you have to take care about rounding problems by yourself.
In my eyes this keeps an error: The function doesn't do,
what you expect and the results could be very ugly.
See down.
2. The float number was printed out as "828" and not as
"827.99999999999999999".
So there must be an explizit float conversion, which does
it "right".
3. Ok, I understand, why round(9.5) is not 10,
but every simple pocket calculator does this simple
thing "right".
[Or Oracle for example:
SQL> select trunc(8.28*100.0,0) from dual;
TRUNC(8.28*100,0)
-----------------
828
mySQL of course too.]
4. For this business applications this behavior of the database
mow saved me my live, cause I could see, if my change in the program
works right: The resulting difference has been above 450
Deutschmark (about $ 200) - this happens when you
calculate about 400,000 operations with this small error.
If you make this little error every day over a
year you pay about $60,000 too much (or too less).
Full Bug description available at: http://bugs.php.net/?id=2835