Calc Builder Support

Calc Builder support
Public write access is disabled. Please login

Working with decimals 21.10.2011 14:30


If purchased the Calc builder.
It is a very nice program exactly what i was looking for.

I got one question.
When i want to work with numbers with decimals (for example 1.5) it works fine.
however it pretty common that people uses 1,5.

Then the program can't calculate it.

Is there a work around for this?
Maybe something in PHP were i can convert it to 1.5 so the program can calculate with the number?

thank you in advance.

Kind regards,

Re: Working with decimals 21.10.2011 14:31


In PHP you can change 1,5 or 1.254,5 in several ways. One easy way is this:

Let´s suppose we want to get a number with this formats : 1.254 or 1.254,10 or 25141,41
We can declare user field in backend as number or text. In this case the "variable" of the field we call as "money".
What we need to do in code?
- Delete all '.'
// with str_replace we replace all . by nothing.
// You can see doc in
// First param is search, second is replaced and third is subject
$first_step=str_replace( '.' , '' , $money);
- Now we can change ',' by '.'
// We can use the same function
// In this second step, our subject is first_step.
$second_step=str_replace( ',' , '.' , $first_step);
- We just finished. In $second_step we have a number in format 0000.00

PHP detects, when you use it in operations, if variables are numbers or strings. Nevertheless you can use "floatval" funtion to ensure you are using a number (in this case float).

// Function docs in

Hope this helps,
Moonsoft Team

Re: Working with decimals 30.05.2016 14:27


I have tried the abovementioned method but it obviously doesn't do what I would like:

I have a field where will enter a number in a EU form (using commas for decimals).

If a number is entered in my form in a "xxx.xx" format, the result is correct.
If a number is entered in a "xxx,xx format", the calculator calculates a xx,xxx.xx number instead, thus rendering a false result.

How could I set the parameters of the calculator so that a number in a "xxx,xx" form would be properly used (using a comma and not a dot for decimals).

Thanks for your help!

Re: Working with decimals 30.05.2016 17:15

well, the above solution was based on code because it's from many years ago and its a code-base solution. With the new versions of Calcbuilder there is an easy way to configure the decimal separator you will allow to use for the front-end. Go to your calculator->preferences tab and scroll down to the section 'thousand and decimal separators', change the decimal separator to comma, and the thousand separator to dot in order to allow the numbers as you need for the calculation.

Hope this helps, regards
Moonsoft Team

Re: Working with decimals 02.06.2016 08:24


I overlooked that setting, obviously :)

Edited by kreatik - 02.06.2016 08:24
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback