This function checks floating point numbers for equality, by using an approximation formula and a fixed precision by constant 1.0E-12 (pico)
LGF_CompareLRealByPrecision (FC) | ||||||||
---|---|---|---|---|---|---|---|---|
LReal | valueA | Ret_Val | Bool | |||||
LReal | valueB | |||||||
LReal | precision | |||||||
Identifier | Data type | Description |
---|---|---|
valueA | LReal | First LREAL number to be compared. |
valueB | LReal | Second LREAL number to be compared. |
precision | LReal | Accuracy with which the two values are compared. |
Identifier | Data type | Description |
---|---|---|
Ret_Val | Bool | FALSE: not equal TRUE: approximately the same |
The comparison of the LREAL numbers is based on an given accuracy at the parameter precision
. The difference between the two input values must be smaller than the precision
accuracy value multiplied by one of the two input values.
Equation:
result := FALSE OR ((#valueA = 0.0) AND (ABS(#valueB) <= #precision)) OR ((#valueB = 0.0) AND (ABS(#valueA) <= #precision)) OR (ABS(#valueA - #valueB) <= (#precision * ABS(#valueA)));Version & Date | Change description | |
---|---|---|
01.00.00 | Simatic Systems Support | |
03.06.2019 | First released version function besad on `LGF_CompareLReal` | |
03.00.00 | Simatic Systems Support | |
23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library | |
03.00.01 | Simatic Systems Support | |
19.01.2020 | Insert documentation | |
03.00.02 | Simatic Systems Support | |
21.12.2023 | Fix compare error if one value is exactly zero |