You are currently reviewing an older revision of this page.

KB-XXXX Unexpected results on decimal calculations

Symptom

Receiving unexpected results for a calculation involving decimals. See some examples below:

Observed: 92000 - (7000.27 + 73000.27 + 2000.33 + 9999.13) = -1.455192e-011

Expected: 92000 - (7000.27 + 73000.27 + 2000.33 + 9999.13) = 0

Observed: round(somefunction) = 15.01000000000000000000000001

Expected: round(somefunction) = 15.01

Cause

This is not a bug with Appian, but it is rather a limitation of the IEEE 754 standard. The Appian Data Type 'Number (Decimal)' is stored as double precision floating-point decimal, which is a 64-bit IEEE 754 floating point. Some numbers have an infinite number of digits and can not be represented with 100% precision with only 64-bits. This is because a base 10 number is being represented as base 2. 

Workaround

fixed() and round()

https://home.appian.com/suite/tempo/news/entry/b-263387

https://home.appian.com/suite/tempo/news/entry/f-236747

https://forum.appian.com/suite/tempo/news/entry/f-233757 

For forms, use one of the following Text Functions to display a decimal number as a default value to avoid rounding.
fixed()
text()
Also for forms, use one of the following currency functions to display a decimal number as a default currency value.
dollar()
euro()
pound()
yen()
currency()