Applies To: |
|
Summary: |
In the CSV_Include project, the CSV_Math_Rounddown() and CSV_Math_Truncate() produce the incorrect results when the operand number’s least significant digit is greater than or equal to 5. That is to say CSV_Math_Rounddown(158.96,0) produces 159 instead of 158. Similarly CSV_Math_Truncate(158.96) produces 159 instead of 158. 158.94 produces the correct result. Using 158.95 produce the correct result because 32bit float its actually 158.949996948242. See Knowledge Base article Q3244. |
Solution: |
This problems exists in CitectSCADA V7 and earlier version projects which utilise the CSV_Include project. The CSV_Math_RoundDown() and CSV_Math_Truncate() code is located in the CSV_Math.ci file in the CSV_Include project. It is recommended not to change the CSV_Include project but to create your own functions within the application project. The following functions should be placed in a cicode file within the project and used instead of those provided in CSV_Include project. REAL
FUNCTION My_Math_RoundDown(REAL rValue, INT
iDecPlaces) sValue
= RealToStr(rValue, 1, iDecPlaces + 2); RETURN
rValueRounded; INT
FUNCTION My_Math_Truncate(REAL rValue) sValue
= RealToStr(rValue, 1, 2); |
Keywords: |
Related Links
Attachments