Is there an accuracy issue with ASP/VBScript with numbers with several decimal places. For example, I am testing a value to see if it is within specification. I have the following code:
if (CDbl(trim(value)) < CDbl(limit - tolerance)) or (CDbl(trim(value)) > CDbl(limit + tolerance)) then
checkLimits = " STYLE=""color: red;"""
pass = false
else
checkLimits = ""
end if
In this case, the value is 0.0027 and the limit is 0.0024 and the tolerance is 0.0003. So basically I am saying:
if 0.0027 < 0.0021 or 0.0027 > 0.0027 then
pass = false
end if
I have checked all the values and printed them out but it always fails saying that 0.0027 is greater than 0.0027. However, if I modify the data so that it is equal to the lower limit (0.0021) it passes - it only seems to fail it when it is equal to the upper limit.
In addition, it only fails for tests with small values. I have another test where the upper limit is 6.1. If the value is equal to this limit, it passes.
This is really frustrating me - I would appreciate it if anyone has any ideas. Mighty
if (CDbl(trim(value)) < CDbl(limit - tolerance)) or (CDbl(trim(value)) > CDbl(limit + tolerance)) then
checkLimits = " STYLE=""color: red;"""
pass = false
else
checkLimits = ""
end if
In this case, the value is 0.0027 and the limit is 0.0024 and the tolerance is 0.0003. So basically I am saying:
if 0.0027 < 0.0021 or 0.0027 > 0.0027 then
pass = false
end if
I have checked all the values and printed them out but it always fails saying that 0.0027 is greater than 0.0027. However, if I modify the data so that it is equal to the lower limit (0.0021) it passes - it only seems to fail it when it is equal to the upper limit.
In addition, it only fails for tests with small values. I have another test where the upper limit is 6.1. If the value is equal to this limit, it passes.
This is really frustrating me - I would appreciate it if anyone has any ideas. Mighty