Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91693 invoked by uid 1010); 6 Aug 2006 08:55:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91678 invoked from network); 6 Aug 2006 08:55:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Aug 2006 08:55:49 -0000 X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 69.179.208.43 msa3-mx.centurytel.net Linux 2.4/2.6 Received: from ([69.179.208.43:50928] helo=msa3-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 03/F5-06633-335A5D44 for ; Sun, 06 Aug 2006 04:15:48 -0400 Received: from pc1 (72-161-60-199.dyn.centurytel.net [72.161.60.199]) by msa3-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k768FiZW016528 for ; Sun, 6 Aug 2006 03:15:44 -0500 Message-ID: <005101c6b930$83f30b30$0201a8c0@pc1> To: Date: Sun, 6 Aug 2006 03:15:44 -0500 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.1807 Subject: is_numeric_string causes function inconsistency From: php_lists@realplain.com ("Matt W") Hi all, Since I've been looking at is_numeric_[string|unicode], I found a weird thing it causes; probably doesn't make sense to users; bug? Look: abs(-1e500) // float(INF) abs('-1e500') // int(1) WRONG abs('-1e100') // float(1.0E+100) is_finite(1e500) // bool(false) is_finite('1e500') // bool(true) WRONG is_finite('1e100') // bool(true) is_numeric(1e500) // bool(true) is_numeric('1e500') // bool(false) WRONG is_numeric('1e100') // bool(true) 1e500 + 123 // float(INF) '1e500' + 123 // int(124) WRONG You get the idea. That's because is_numeric_string() *ignores* the value from zend_strtod() if errno==ERANGE. I don't think that's right, and it doesn't happen when convert_to_double() uses zend_strtod(): number_format(1e500) // string(3) "inf" number_format('1e500') // string(3) "inf" RIGHT Just wondering if others think is_numeric_string() should be changed in that respect? I was going to rewrite the function to improve/optimize it (and submit it of course), so I can easily change its behavior while I'm at it... Also, is this the desired behavior of array_count_values() (manual doesn't say; it also uses is_numeric...)? print_r(array_count_values(array(1, ' 1', ' 1 '))) Array ( [1] => 2 [ 1 ] => 1 ) Matt