printf(%.2f,$number);
Shaun wrote:
Hi,
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?
Thanks for your help
--
http://www.radinks.com/upload
Drag and Drop File Uploader.
--
PHP General
Hi
Am Die, 2003-09-09 um 16.06 schrieb Shaun:
Hi,
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?
Use printf with format strings like printf(Value: %.2f, $value);
[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
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]
[snip]
It is not mentioned in the manual, but it seems dec_point cannot be
empty. If it is empty, default (.) is taken.
echo number_format($number, 4, '', ',').\n;
number_format() does allow an empty set of single quotes in the third
attribute which it will default to a period (.) for the
I meant you cannot set decimal point to be '', it will always display.
Yes you can supply '' for the third argument.
Jay Blanchard wrote:
[snip]
It is not mentioned in the manual, but it seems dec_point cannot be
empty. If it is empty, default (.) is taken.
echo number_format($number, 4,
[snip]
I meant you cannot set decimal point to be '', it will always display.
Yes you can supply '' for the third argument.
[/snip]
Ah!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
7 matches
Mail list logo