Matt W wrote:
Hi,
Haven't heard any opinions on these functionality changes... (Though I know
more significant things keep you busy!)
Do many other people use number_format()?? Wouldn't allowing thousands
separator as param #2 simplify things?
Any issues with the semantics of operation? Negative precision to specify
trailing zero removal seems fine at least, even though that's different than
round()'s behavior.
I've now made some tests, including changes of course, in case you were just
waiting for them? Hope they're enough.
http://realplain.com/php/number_format.phpt
Sorry , I did not come better than the attached test
copies http://toggg.info/number_format.phpt &
http://toggg.info/number_format.diff
(you don't need "\n")
I wonder why lines are fliping , I guess it's a diff effect
Let me know how I apply your patch , so I get it blank :)
--
toggg
--TEST--
number_format() function
--FILE--
<?php
echo
"Numeric string decimals
",
number_format(12345, '0'), "
",
number_format(1234.51005, '4'), "
",
"Custom decimal point and thousands separator
",
number_format(-12345, 1, ',', ' '), "
",
number_format(-1234.51005, 4, ',', ' '), "
",
"No decimal point
",
number_format(0.1234, 3, '', ','), "
",
number_format(12345678.9, 2, '', ','), "
",
"Big number
",
number_format(1e16, 8), "
",
"Many decimals
",
number_format(12345, 400), "
",
"Minimal decimals (no trailing zeros)
",
number_format(9.87654, -3), "
",
number_format(-12345, -20), "
",
number_format(1234.51005, -3, '.', ' '), "
",
"Thousands separator as second parameter
",
number_format(1234.5, ''), "
",
number_format(12345, ','), "
",
number_format(12345, ' '), "
",
number_format(9876543.33, '.'), "
";
?>
--EXPECT--
Numeric string decimals
12,345
1,234.5101
Custom decimal point and thousands separator
-12 345,0
-1 234,5101
No decimal point
0123
12,345,67890
Big number
10,000,000,000,000,000.00000000
Many decimals
12,345.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Minimal decimals (no trailing zeros)
9.877
-12,345
1 234.51
Thousands separator as second parameter
1235
12,345
12 345
9.876.543
008+ 123
009+ 1,234,567,890
008- 0123
009- 12,345,67890
015+ 10
015- 9.877
017+ 1 235
017- 1 234.51
019+ 1,235
020+ 12,345
019- 1235
021- 12 345
022+ 9,876,543
022- 9.876.543
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php