Fuzzy comparison and output values of a state table
Fuzzy comparison is used to compare uncertain or imprecise data. For example: .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 (.1 added 10 times) does not equal 1.0 because .1 cannot be stored exactly in floating point format. (The value is represented as a repeating bit pattern, like 1/3 = .333... in decimal.)
Fuzzy comparison provides a way to ensure that input expression values are consistently calculated and compared with the Expression Values to ensure predictable output values.
For example, two values are determined equal if the following inequality is true:
| value1 - value2 | <= 0.00001 * Min( | value1 |, | value2 | )
or stated another way:
AbsoluteValue("0.00001"( value1 - value2 ) <= (1.0 E-5) * SmallerValueOf( AbsoluteValue( value1 ), AbsoluteValue( value2 ) )
The fuzzy comparison algorithm uses the resolution factor of 0.00001 because Logix controllers use the REAL data type to store floating point data. The REAL data type stores values to seven or eight significant digits of precision. When using floating point numbers:
- Do not specify more than five significant digits for the Expression Value.
- Because 32-bit floating point values have, at most, approximately 7.2 significant digits, and Logix 5000 encodes its real value as an eight-digit string, the least significant digit (LSD) may be an invalid digit. However, the LSD is still compared as if it is a valid digit. Verify that the eighth digit is valid.For example, typing 3123.45111 into a Logix 5000 tag value is saved as 3123.4512. If the eighth digit (LSD) is valid, it saves as 3123.4511.
Provide Feedback