CalcBuilder Forum

2 Digits Result

Usuario JoeCool 2011-12-06 00:19:54

Hi,
after some operations, i've gotr a result. However i would like the result to be a 2 digits result, like 215.60€. I can only have an answer like 215.5985€.
Is there an easy way to obtain that kind of result ?
Thanks for your help.

Moonsoft support 2011-12-06 11:59:28

Hello,
to format numbers before showing the results, you should use number_format function, where you can specify number of decimals and decimal/thousand separators. Usually this should be done at the last lines of the code, when all math is finished. To check an example we suggest to download and import the example calculator '4 basic operations & formatting numbers' here:

http://components.moonsoft.es/downloadcalcbuilder

where you can see how different formatting are applied to the results.

Hope this helps, best regards
Moonsoft Team

Usuario JoeCool 2011-12-06 12:28:40

Thanks, works like a charm !
Have a nice day.

...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!