#24891 [Bgs]: Decimal equality incorrect result
| From: | jeff at tmtrading dot com | Date: | Thu, 31 Jul 2003 18:52:46 +0000 |
| Subject: | #24891 [Bgs]: Decimal equality incorrect result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-45131@lists.php.net to get a copy of this message | ||
ID: 24891
User updated by: jeff at tmtrading dot com
Reported By: jeff at tmtrading dot com
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Win2000 & RH Linux 8.0
PHP Version: 4CVS-2003-07-31 (stable)
New Comment:
This is stupid. PHP is a loosely typed language, it's not frick'n C!
If I don't have to declarde my variables, I should be able to count on
the language to fix things for my automagically.
Python and Perl are esentailly in the same language category as PHP.
Loosely typed languages should handle these situations automatically.
Where can I find information on why the decision was made to do things
so stupidly?
Previous Comments:
------------------------------------------------------------------------
[2003-07-31 13:35:13] sniper@php.net
RTFM:
http://fi2.php.net/manual/en/language.types.float.php
------------------------------------------------------------------------
[2003-07-31 13:32:22] jeff at tmtrading dot com
Description:
------------
When I try to test equality using these numbers php incorrectly returns
false. This is a serious problem as we are developing a e-cart in php.
Reproduce code:
---------------
$all = 0.92;
$asum = 0.71;
$bsum = 0.21;
if($all == ($asum + $bsum)) {
print "TRUE\n";
} else {
print "FALSE\n";
}
Expected result:
----------------
TRUE
Actual result:
--------------
FALSE
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24891&edit=1