Page 1 of 1
Why {29.19 + 0.05} = 29.24000000002
Posted: 07 Jul 2018 17:28
by natong

- Screenshot_2018-07-08-00-25-19-030.jpeg (264.8 KiB) Viewed 11060 times

- Screenshot_2018-07-08-00-28-51-789.jpeg (294.72 KiB) Viewed 11060 times
Please suggestion.
Re: Why {29.19 + 0.05} = 29.24000000002
Posted: 08 Jul 2018 17:56
by Desmanto
floating calculation problem. At times, it will throw such problem. You have to round it. Unfortunately we don't have round() with extra argument to limit the decimal yet. You can use either one of these solution
Code: Select all
a = 29.19 + 0.05 ; // result = 29.24000000002
b = round(a*100)/100; // result 29.24
c = "{a,numberformat,0.00}"; // result 29.24
The b is using universal rounding method, it can round to any number (to round to nearest 7, replace the 100 with 7).
While c is using automagic built-in pattern character to show the number in 2 decimals.
Re: Why {29.19 + 0.05} = 29.24000000002
Posted: 09 Jul 2018 10:36
by natong
Thank. These bug will be fixed in the next version ? or it's android floating bug and can't be fixed ?
Re: Why {29.19 + 0.05} = 29.24000000002
Posted: 09 Jul 2018 12:29
by digitalstone
Not even Android i think. More a fundamental problem/side effect.
Re: Why {29.19 + 0.05} = 29.24000000002
Posted: 09 Jul 2018 17:41
by Desmanto
Yeah, I think it is featured, as Automagic scripting is inherited from java/javascript. Besides, floating calculation problem is
a common problem. We have to deal with it, just use round or other method to show it properly. I use both b and c method depends on my need.