cancel
Showing results for
Did you mean:
Regular Visitor

## decimal calculation bug

I found following bug.

So Please tell me solutions to fix.

---

1-0.8
→0.199999999..... (0.2 is expected)

I also found following solution,

But I can not understand the reason It works well.

---

Value(Text(1-0.8))
→0.2

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

Hi @kazuki77777 ,

This is not a bug, this is a feature of floating-point arithmetic .  Floating-point arithmetic is approximate, so it can sometimes give unexpected results with many documented examples. You might expect the formula 55 / 100 * 100 to return exactly 55 and (55 / 100 * 100) - 55 to return exactly zero. However, the latter formula returns 7.1054 x 10–15, which is very small but not zero. That tiny difference doesn't normally cause a problem, and the app rounds it away when showing the result. However, small differences can compound in subsequent calculations and appear to give the wrong answer.

https://learn.microsoft.com/en-us/power-platform/power-fx/data-types#number-and-currency

Best Regards,

Bof

2 REPLIES 2
Community Support

Hi @kazuki77777 ,

This is not a bug, this is a feature of floating-point arithmetic .  Floating-point arithmetic is approximate, so it can sometimes give unexpected results with many documented examples. You might expect the formula 55 / 100 * 100 to return exactly 55 and (55 / 100 * 100) - 55 to return exactly zero. However, the latter formula returns 7.1054 x 10–15, which is very small but not zero. That tiny difference doesn't normally cause a problem, and the app rounds it away when showing the result. However, small differences can compound in subsequent calculations and appear to give the wrong answer.

https://learn.microsoft.com/en-us/power-platform/power-fx/data-types#number-and-currency

Best Regards,

Bof

Regular Visitor

I understand that text field is one of the best solutions in this case.

Announcements