Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27066 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14969 invoked by uid 1010); 18 Dec 2006 13:36:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 14953 invoked from network); 18 Dec 2006 13:36:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Dec 2006 13:36:55 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 209.142.136.51 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.142.136.51 neville-out.centurytel.net Linux 2.5 (sometimes 2.4) (4) Received: from [209.142.136.51] ([209.142.136.51:36010] helo=neville-out.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/E1-02261-35996854 for ; Mon, 18 Dec 2006 08:36:54 -0500 Received: from msa2-mx.centurytel.net (msa2-mx.centurytel.net [209.142.136.132]) by neville-out.centurytel.net (Postfix) with ESMTP id 97C8815FC5F for ; Mon, 18 Dec 2006 07:00:39 -0600 (CST) Received: from pc1 (d3-37.rb.ot.centurytel.net [69.29.126.37]) by msa2-mx.centurytel.net (8.13.6/8.13.6) with SMTP id kBICtfMH026458; Mon, 18 Dec 2006 06:55:41 -0600 Message-ID: <016e01c722a3$d35c3e80$0201a8c0@pc1> To: , "Ilia Alshanetsky" References: <014f01c71dfd$f0431cd0$0201a8c0@pc1> <018301c71e06$9ef4f840$0201a8c0@pc1> <019301c71e08$9837bdb0$0201a8c0@pc1> Date: Mon, 18 Dec 2006 06:55:42 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Subject: Re: [PHP-DEV] [PATCH] New, optimized is_numeric_string, and other number stuff From: php_lists@realplain.com ("Matt Wilmas") Hi Ilia, all, I was just looking at zendi_smart_strcmp() and realized something I hadn't considered (more on that in a sec.). First, and unrelated to the new is_numeric_*, because _smart_strcmp() uses zend_strtod() if one operand is a double and the other isn't, it results in ('0.0' == '0x123') being TRUE! Seems like a bug. I think a (double) cast can be used there instead of zend_strtod(), since that's what's done in compare_function()? Would be faster too... All right, now what's different with my new is_numeric_* functions: previously is_numeric_* ignored doubles that overflowed (INF), and returned 0 -- think like 500 digits -- and the operands would be compared as strings. So 2 strings that overflowed wouldn't wrongly be considered equal, I assume. Now that's different with IS_DOUBLE being returned always, which is appropriate for most cases like arithmetic. And it wasn't just overflown numbers that previously returned 0, but underflown also ('1e-1000' or a VERY small decimal number; they set ERANGE). I think the simplest way to keep the old behavior with the new is_numeric_* is to use errno in zendi_smart_strcmp(). That'll make it a little slower, but no slower on longs than the old version I don't think, and it'll still be much faster with doubles/non-numeric strings. Any other thoughts on how it should be handled? That is the correct and desired behavior to only compare numerically if both values can be accurately represented? I'll update the patches ASAP once I find out what to do... Matt ----- Original Message ----- From: "Ilia Alshanetsky" Sent: Tuesday, December 12, 2006 > Matt, > > Take a look at array.c and wddx.c > > On 12-Dec-06, at 11:14 AM, Matt Wilmas wrote: > > > ----- Original Message ----- > > From: "Ilia Alshanetsky" > > Sent: Tuesday, December 12, 2006 > > > >> As far as I can tell all tests still pass with the patch, although we > >> have a number of is_numeric_string() uses that will need to be > >> adjusted to accommodate the change to the function. > > > > Really, like what? I didn't see anything that stuck out... > > > >> Ilia Alshanetsky > > > > Matt > > Ilia Alshanetsky