Trim decimal places
Moderator: General Moderators
Trim decimal places
I've got number in format 35603.822252
How to leave only two numbers after decimal decimal '.'? (trim or something)
I know that exist 'number_format($number, 2, ’.’, ’.’)' command, but I do not want to use this.
One more thing how to get formating number 35,603.82 to 35.603,82
How to leave only two numbers after decimal decimal '.'? (trim or something)
I know that exist 'number_format($number, 2, ’.’, ’.’)' command, but I do not want to use this.
One more thing how to get formating number 35,603.82 to 35.603,82
Last edited by ddragas on Tue Jul 12, 2005 3:59 pm, edited 2 times in total.
Re: Trim decimal places
Why Not?ddragas wrote: I know that exist 'number_format($number, 2, ’.’, ’.’)' command, but I do not want to use this.
Becouse Im using function viewtopic.php?t=33582 (author Burrito) and it is returning text 'Thirty Five Thousand Six Hundred and Three Point Eight Hundred and Twenty Two Thousand Two Hundred and Fifty Two'
So I need to trim all but two decimals
So I need to trim all but two decimals
Isn't that what you want? Do you want the string representation or do you want the digits themselves?
As for you second question:
As for you second question:
http://www.php.net/number_formatPHP Manual wrote:string number_format ( float number [, int decimals [, string dec_point, string thousands_sep]] )
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
The problem is the thousands separater. Call number format like this:
That will remove the thousands separator, and allow ~Burrito's code to work properly.
Code: Select all
number_format(35603.822252,2,'.','');
Last edited by pickle on Tue Jul 12, 2005 5:10 pm, edited 1 time in total.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.