Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90724 invoked by uid 1010); 2 Aug 2006 10:45:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 90709 invoked from network); 2 Aug 2006 10:45:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Aug 2006 10:45:40 -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:56090] helo=msa3-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 7A/B9-45114-25280D44 for ; Wed, 02 Aug 2006 06:45:40 -0400 Received: from pc1 (64-91-15-129.dyn.centurytel.net [64.91.15.129]) by msa3-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k72AjZwW031886 for ; Wed, 2 Aug 2006 05:45:35 -0500 Message-ID: <00e501c6b620$c9a880f0$0201a8c0@pc1> To: Date: Wed, 2 Aug 2006 05:45:36 -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 and general string-to-number conversion From: php_lists@realplain.com ("Matt W") Hi there, I've been looking at the different string->number related functions lately. It looks like is_numeric_[string|unicode]() could be optimized. Here's what I was thinking: Can functions like zend_[string|unicode]_to_number() be added? Then is_numeric_* could always call only 1 function that would handle long and double (like in _php_math_basetozval). Now strtol() or zend_strtod() can be called unnecessarily, depending on the scenario. BUT, in order for me to do this, *can* doubles/floats be handled correctly/accurately using simple code such as in the existing zend_string_to_double()? So you know what I mean, the function prototype might look like this: zend_uchar zend_string_to_number(char *str, char **end, int base, long *lval, double *dval) This is the type of function I think would be nice (on its own) where I was updating PHP's dec*() functions to handle larger values -- is_numeric_string/convert_scalar_to_number aren't right, IMO, because they allow hex strings (in dechex()?? :-)), besides being more inefficient because of the current is_numeric_string. I was looking for more of a plain convert_to_number, like convert_to_long, but would use a double if needed. Thoughts? Thanks, Matt