CalcBuilder Forum

decimal places

User Gerald Helbig 2024-11-19 08:32:50

Hello,
Where can I define the decimal places? For example, the result is displayed as 5 €. But I want to display 5.00 €.
Thank you for your help.
Best regards.
Gerald

Moonsoft support 2024-11-19 09:27:20

Hi,
there are several ways to format the output. If you use a spreadsheet for calculations you can try to apply a format there, so the result will be recovered using your preferred format. In addition, you can manually format any output at the php section. Once you have calculated your output, for ex at the variable
$result
you can use the number format function to round, format, and assign any custom decimal or thousand separator, this way:

$result=number_format($result,2);

//this will return the number with 2 decimal places

$result=number_format($result,2,","," ");
//this will return the number with 2 decimal places, with a blank space for thousand separator, and a comma for decimal separator.
Here the page with further information and some examples for this function:

https://www.php.net/manual/en/function.number-format.php


Hope this helps, regards
Silvia Martín
Moonsoft Team

User Gerald Helbig 2024-11-19 20:01:31

Hi Silvia,
Thank you very much for the quick response and the very good help. I used the PHP option and it works perfectly..
Best regards.
Gerald

Moonsoft support 2024-11-20 09:32:37

Hi!
perfect, great it worked. We close the ticket with this solution, please open a new one in case you have any other question.

Thanks, regards
Silvia Martín
Moonsoft Team

...
Support/development 10 hours

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

Buy now!
...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!