Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43852 invoked by uid 1010); 19 Jul 2006 10:54:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 43837 invoked from network); 19 Jul 2006 10:54:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2006 10:54:38 -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:50167] helo=msa3-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 2B/0E-11992-D6F0EB44 for ; Wed, 19 Jul 2006 06:54:37 -0400 Received: from pc1 (d6-227.rt-bras.wnvl.centurytel.net [69.179.133.227]) by msa3-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k6JAsXHl032072 for ; Wed, 19 Jul 2006 05:54:34 -0500 Message-ID: <007001c6ab21$b8d560e0$0201a8c0@pc1> To: Date: Wed, 19 Jul 2006 05:54:34 -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: [PATCH] number_format enhancements From: php_lists@realplain.com ("Matt W") Hi, There are a couple things I don't like about how number_format() works currently, so I'm hoping the functionality changes this patch provides can be added. :-) First is that when you're working with whole numbers and/or don't want any decimal places, both decimal-related parameters are needed before the thousands separator. I always thought it would be logical to pass the thousands separator as param #2 in those cases. That's what my changes allow if it's a non-numeric string. Second is that when decimals places ARE specified, I would like to be able to have trailing zeros/point removed. (Like "(string) round(...)" but never scientific notation.) I'm sure I'm not the only one that has wanted grouped thousands and/or custom decimal point *without* trailing 0's. :-) The patch allows this by specifying negative decimal places -- e.g. -2 is 2 decimals without extra zeros. Are these enhancements all right? If they're agreed to, I'll create more number_format() tests right away if desired. Just wanted to get any thoughts on the patch first. Also, I changed PHP_ROUND_WITH_FUZZ to skip unnecessary steps if places==0 (round() is nearly 20% faster then, in my quick tests), corrected the misspelling of "separator" in the proto, and simplified some of the code. http://realplain.com/php/number_format_enhancements.diff http://realplain.com/php/number_format_enhancements_5_2.diff Thanks, Matt