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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php