It is not mentioned in the manual, but it seems dec_point cannot be empty. If it is empty, default (.) is taken.

Jay Blanchard wrote:
[snip]
I am dividing a number by another number and printing the result to the
screen. How can I ensure that the number is rounded up to 2 decimal
places?
[/snip]

Why others never test these things I'll never know...but here is a small
test you can run....

<?php

/*
** rounding / number format test
*/

$number = 12.2345;

echo number_format($number, 4, '', ',')."\n";
echo number_format($number, 3, '', ',')."\n";
echo number_format($number, 2, '', ',')."\n";
echo "\n";
echo round($number, 4)."\n";
echo round($number, 3)."\n";
echo round($number, 2)."\n";
?>

The results ....

12.2345
12.235
12.23

12.2345
12.235
12.23

Interesting, no? It would appear that under PHP4.2.1 on a test server
that number_format() exhibits the same behaviour as round().

Have a pleasant and productive day.


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to