Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Numbers after comma 28.08.2014 09:13

Hi, how can I limit to 2 the number of decimal after the comma?
Example: 51,12% not 51,123456789%

This is the PHP code that I used to calculate percentage:

$myresult=100/$number1 . '%';

Thanks

Re: Numbers after comma 28.08.2014 10:12

Hi,

You should use number_format php function (http://php.net/manual/es/function.number-format.php) like this:

$myresult=number_format((100/$number1),2) . '%';

If you want to decimal point of thousand separator, you should add 2 parameters to number_format function (Check docs).

Regards,
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Our clients' feedback