• Hi Jan,

this is just how floating point arithmetics work. See http://floating-point-gui.de/ for an explanation and ways around it.

Best,
Stefan

• Hi Jan,

it's not a Podio problem. If you select "2 decimals" in the field options, it's only the option how many decimals should be shown. The number in the "background" which is used for the calculation is the full number with all decimals. So you have to fix the decimals with Javascript. You can try:

``````kostennetto = +(((kostennetto + mwst)/0.01)*0.01).toFixed(2)
``````

Rainer

• Thanks!
@Stefan: The link is good knowledge. Didn't know.
@Rainer: Works!
Another workaround I found was toString & parseFloat. It's not that good, but it kinda also works.

• .toFixed() does the same with a number as toString() (but sets decimals too), + in this case the same as parseFloat (converting it back to a number).

• Ah ok, very nice!

• Jan,
I am using .toFixed(2) in a calculation field to convert a currency field to text so that it displays the correct number of decimal places when exported to a word document using WebMerge.
I don't have thousands separation anymore. Is there a workaround for this?
Many Thanks,
John.

• Hi John,

I use this to get the thousand separator (,):

`````` Field.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '\$&,')
``````

Rainer
rg@delos-consulting.com

• Perfect. Thank you!

• This worked perfectly for me.

``kostennetto = +(((kostennetto + mwst)/0.01)*0.01).toFixed(2)``

Rainer you're amazing at this calculation stuff!  Thank you.

• The rounding solution is for users of Javascript only!! What would be the workaround within Podio's calculation field??

James

• Hi James,

everytime you enter something in a calculation field, you use Javascript. Calculation fields are based on Javascript.

If you only add a token into a calculation field like

@AVG of some field

you can define the number of decimals in the feild settings (which rounds the result): Rainer

• Hello Guys & Podio,

My rounding problem is before,00 - I need to round the result up to nearest 5. I have used some of your java solutions before, and now I found 2 one at php.net and one on Stack Overflow, I can not get them to work.
But then again, I know nothing about java or php.

I would appreciat any help, thanks

It says

``````float ceil ( float \$value ) ----<?phpecho ceil(4.3);    // 5echo ceil(9.999);  // 10echo ceil(-3.14);  // -3?>----function round5(x)
{
return Math.ceil(x/5)*5;
• Hi Hans,

PHP and Java solutions don't help cause the Podio calculation field uses JavaScript (and yes, Java and JavaSript are completly different things).

If you want to round an integer to the nearest 5 (= round up or down)

`var val = 22;Math.round(val/5)*5 `

Result: 20

If you want to round to the next 5 (= always round up)

`var val = 22;Math.ceil(val/5)*5`

Result 25

A function you only need if you've many number values in your calculation and if you want to avoid  to enter the formula for each one

``````function round5(x)
{
return Math.ceil(x/5)*5;
};round5(numberA) + round5(numberB) + round5(numberC)``````

Rainer