php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24891 Decimal equality incorrect result
Submitted: 2003-07-31 13:32 UTC Modified: 2003-07-31 14:01 UTC
From: jeff at tmtrading dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4CVS-2003-07-31 (stable) OS: Win2000 & RH Linux 8.0
Private report: No CVE-ID: None
 [2003-07-31 13:32 UTC] 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

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-31 13:52 UTC] jeff at tmtrading dot com
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?
 [2003-07-31 14:01 UTC] sniper@php.net
ROFLMAO..please, don't go any further with this nonsense, you'll just make bigger fool of yourself. :)


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Aug 25 09:01:27 2024 UTC