Forum Academy Marketplace Showcase Pricing Features

Rounded to is not rounding properly

I’ve created a forum app page to show a calculation that isn’t rounding properly. I’m not sure if I have input things incorrectly but I created a button that would multiply an input by 1.13 and then round the result to 2 decimal places.

Depending on the input it will round correctly or not

Example calculations:
408.50 --> 461.6 (should be 461.61)
187.50 --> 211.87 (should be 211.88)
112.50 --> 127.12 (should be 127.13)

I thought it was just not rounding up, but it will do this correctly:
262.5 --> 296.63

That’s probably a Javascript way of doing it, not sure we want to overwrite the standard behavior there. JS can have weird stuff sometime…

Thks @hvac_designer for reporting this.
What you can do is *100 :ceiling /100. Then you’re result will be round up. Or another workaround is to add +0.001 before rounding.

But I’d consider it as a bug as well. Read here or here about rounding integer :

The round() method rounds a number to the nearest integer. 2.49 will be rounded down, 2.5 will be rounded up.

@emmanuel it seems the issue can be avoided using exponantiel source :

.round(1.005+‘e2’)+‘e-2’

2 Likes

I think I will just add 0.001 before the round to function as this seems to work. I found out a few other things along the way in testing this further:

It will round differently if you are trying to multiply then round or if you are just rounding. For example, if I multiply 408.50 x 1.13 (which equals 461.605) and round to 2 decimals, the result is 461.6 and is incorrectly rounded down. However if the workflow is just rounding 461.605 to two decimal points it will correctly round up!

Also, it does not really matter what decimal points are being rounded up. For example 1.005 is incorrectly rounded down, but 2.005, 3.005, etc are correctly rounded up.

As for the exponential source solution, I dont believe that is something we can program in the workflow is it?

1 Like

thanks for the details
no exponantial available in the workflow. that was for emmanual not for us.