CalcBuilder Forum

demical points dont show

Usuario moon_1066 2013-05-30 14:37:54

Hi there we have set the result to diplay to two decimal points. Could you help us witha small problem. the results show up and work fine but if the result amount does not need two decimals it removes the zero

For example if result is 3.56 it works but if result is 3.30 its drops the zero and displays it as 3.3

Because this is a currency value i need the zero to show up please help with this

Moonsoft support 2013-05-31 09:02:15

Hello,
in order to have fixed decimal positions, you have to apply a format to the number once you have finished calculations. Assuming that you have your number stored at the variable $result, you should add this line at the end of your code section:


$result=number_format($result,2);


This will format the number to 2 decimal positions.

More information and examples about number_format function here:


http://php.net/manual/en/function.number-format.php


Hope this helps, regards

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!