CalcBuilder Forum

decimal points and calculation error

Usuario moon_943 2013-03-13 15:35:09


I built a form, and added the decimal points in php as the commas and dec points weren't rendered even though I added in preferences.

I do have joomla 1.5 version. My calculations do else work fine, but not the last one:







Frontend result:

result_1 ok
result_2 ok
result_3 ok
ratio ok
result wrong


Anybody out there who can tell me what I did wrong?

Thank you in advance

Kind regards


Moonsoft support 2013-03-13 15:54:02


You´re trying to add $result_1 and $result_2 and so on to get $result. The problem is that $result_1 is a String, not a number. You should save $result_1 as number before applying number_format function and then use it.

Code looks like this:





Hope this helps.

Usuario moon_943 2013-03-18 09:24:18

Thank you so much for helping! It's still not working right, unfortunately.
shouldnt that as well define the variables as numbers: $result_1=number_format($result_1,2,',','.');?

I know that if you try the calculation with 200 employees and 135 wage you finally should retrieve following numbers:


(1,2 % af den årlige lønomkostning)
Omkostninger: 499.500,00 kr. pr. anno
-> should be: 600.000,00

TOTAL= 108.054,00
-> should be: 763.620,00

Moonsoft support 2013-03-19 12:08:14


Number format is not used to define variables as numbers, but to format them. So, you only have to perform all calculations without using number_format function and once all results are calculated execute number_format function as the last lines of your calculators.


Usuario moon_943 2013-03-19 14:36:52

Now I figured it out!

Thank you sooo much indeed :-)

Cheers from Denmark to lovely Spain



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

Buy now!
List Manager

Build different lists for your site

Buy now!