Why do calculations with decimal numbers sometimes yield inaccurate results.

 Document ID : KB000071337 Last Modified Date : 19/02/2018 Show Technical Document Details
 Question: Some Gen calculations with decimal numbers can produce inaccurate results. What can cause this? Answer: Any time a floating-point data type (float or double) is used, the possibility of a loss of precision exists because of the way floating-point numbers are stored. A loss of precision is possible even if there is no mathematical operation on the floating-point data types, i.e. just storing a number in a floating-point data type can be enough for a loss of precision to occur. Gen generates floating-point data types in either of the following cases: An attribute is defined with decimalsAn attribute has length greater than 9 digits. Therefore to ensure numeric accuracy, it is recommended to turn on the Decimal Precision property for any numeric attribute that meets either of the following two conditions: Number of decimal places > 0Length of attribute is > 9 (even if number of decimal places = 0) Examples:If an attribute is declared with a length of 8 and with 2 decimal places (8,2), that meets condition 1 above, so Decimal Precision should be checked.If an attribute is declared as a 10 digit integer (10,0), that meets condition 2 above, so Decimal Precision should be checked.In addition calculations should be set to ROUNDED to ensure no loss of accuracy.