Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37401 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6956 invoked from network); 2 May 2008 16:52:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 May 2008 16:52:19 -0000 Authentication-Results: pb1.pair.com header.from=jbondc@openmv.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jbondc@openmv.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain openmv.com from 64.15.152.204 cause and error) X-PHP-List-Original-Sender: jbondc@openmv.com X-Host-Fingerprint: 64.15.152.204 mail.ca.gdesolutions.com Received: from [64.15.152.204] ([64.15.152.204:61734] helo=mail.ca.gdesolutions.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/C0-01733-0C64B184 for ; Fri, 02 May 2008 12:52:17 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id B71D45C25 for ; Fri, 2 May 2008 12:52:14 -0400 (EDT) X-Virus-Scanned: amavisd-new at gdesolutions.com Received: from mail.ca.gdesolutions.com ([127.0.0.1]) by localhost (mail.ca.gdesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id faJTQQGJqg7q for ; Fri, 2 May 2008 12:52:11 -0400 (EDT) Received: from jbondc (modemcable158.97-203-24.mc.videotron.ca [24.203.97.158]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 677875C20 for ; Fri, 2 May 2008 12:52:11 -0400 (EDT) To: Date: Fri, 2 May 2008 12:52:10 -0400 Message-ID: <001401c8ac74$dda6d060$98f47120$@com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0015_01C8AC53.56953060" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcisdNz744NAUZD4TtSKV92wJvcG5A== Content-Language: en-ca Subject: Float comparison From: jbondc@openmv.com ("Jonathan Bond-Caron") ------=_NextPart_000_0015_01C8AC53.56953060 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, I'm new to the PHP internals list and I'm posting an issue I'm sure has been mentioned before -- float comparison I'd like to know if there are reasons not to change the default behavior when comparing floats. i.e. This would seem logical to me: $test = 19.6*100; if((float)(string)$test == (double)1960) echo "GOOD BEHAVIOR"; // Implicitely convert the float to string then float (en_US locale) if($test == (double)1960) echo "THIS SHOULD PASS by casting (float)(string)$test internally..."; else echo "NOT GOOD BEHAVIOR"; // Exact comparison would still fail if($test !== (double)1960) echo "GOOD BEHAVIOR"; Any reason why $test == (double)1960 should fail? I realized we are comparing two floats, but couldn't php internally convert to string then float - for the non strict (===) case Thanks ------=_NextPart_000_0015_01C8AC53.56953060--