ryanck
March 6, 2017, 11:10am
1
Hello,
I´ve found that whenever we´ve a calculation of an invoice total that is something like 1.208,665 € and you do the “format as currency and 2 decimals” Bubble rounds the 665 to 67 so you get 1.208,67 € and it should be 1.208,66 €.
Is there any way to fix this? Since it´s getting a lot of issues when moving the invoices to our accounting program because the accounting app checks the calculation and it says that it should be 1.208,66 € instead of ,66 so it won´t let us import the invoices.
Thanks a lot everyone.
Bests.
ryanck
March 6, 2017, 11:30am
3
Sorry Nigel, what do you mean?
We have to keep in mind that it´s one case so we cannot do for every calculation just when that happens.
NigelG
March 6, 2017, 11:41am
4
Sorry, I mean 0.005.
So when you store the invoice total, every time you subtract 0.05 and round up. That is the way to round to the nearest 2 dp.
ryanck
March 6, 2017, 11:45am
5
But what happens if it´s 1.208,6656 for example?
Also I´ve tried to see the subtract in the workflow calculation but there is nothing there.
Thanks a lot.
NigelG
March 6, 2017, 11:55am
6
I was getting confused by the , and . being the other way round to anglo-saxons
1208.6656 - 0.005 = 1208.6606 so round it up … 1208.67.
1208.6646 - 0.005 = 1208.6596 so round it up … 1208.66.
At least that is what I think you are after.
ryanck
March 6, 2017, 12:03pm
7
But there is a problem there, what if the number is just 10 €, if I subtract 0,005 then it will be 9,995 €
Then we have a problem, hehe
What do you think?
NigelG
March 6, 2017, 12:05pm
8
That will round up to 10.
ryanck
March 6, 2017, 12:08pm
9
Uf I don´t know if this solution is a good idea since we´re working with numbers and I need to check if there will be an issue because it could be any number.
Don´t you think?
ryanck
March 6, 2017, 12:10pm
10
Just tried that and it rounds to 9.99
NigelG
March 6, 2017, 12:17pm
11
You are right, it does.
So you want to round down to the nearest dp 2 each time ?
(I had thought Bubble always rounded up).
mishav
March 6, 2017, 12:34pm
12
Try @NigelG ’s method, but specifically round it to two digits, instead of relying on the formatting:
number - 0.005 :rounded to 2
And maybe raise a bug on the formatting not being consistent?
NigelG
March 6, 2017, 1:42pm
13
It is a bit weird, and I was fairly certain it rounded .5 up, but it appears to round it down.
So - 0.05 then +0.0001 should do it.
But … I tend to agree that it isn’t particularly robust.
ryanck
March 6, 2017, 3:42pm
14
Thanks a lot but I think I´ve to digg in a little bit since it´s getting complicated to find a pattern.
mishav
March 7, 2017, 12:32am
15
Maybe this helps… to output the number, there are two stages:
Change the value to stop after two digits. Alternatives:
subtract 0.005
, then :round 2
multiply by 100
, then :floor
, then divide by 100
133 stays as 133
133.999 becomes 133.99
Show the changed value with two digits. Use the :formatted as 1.234,56
133
shows as 133,00
133.99
shows as 133.99
Both stages can be done in the same expression.
DaveA
March 7, 2017, 3:31am
16
I haven’t looked at this, but are they applying Bankers rounding (Round half to Even)?
I think the standard JS Round() function goes to the nearest integer with .5 always going UP.
Here are the different rounding methods… https://en.wikipedia.org/wiki/Rounding
jason1
March 20, 2018, 10:59pm
17
Regarding Bankers Rounding, where:
2.5 is rounded to 2
3.5 is rounded to 4
4.5 is rounded to 4
How do you achieve this type of rounding in bubble?
For instance-
Item Subtotal is $79.00
7.5% Sales Tax is $5.925
We need this to end up as .92
If it were .935, we’d need it to round up to .94
I really appreciate any help or pointers. Thanks!
This is actually still a relevant topic. Is there absolutely no reliable way of cutting any long number down without rounding? E.g. 0,136666667 → 0,13
:rounded to
will round to 0,14
:formatted as
will also round to 0,14
Thank you!
@hi_bubble [number] * 100:floor / 100
1 Like
This works for me. Thanks.
1 Like