Hi all, I'm encountering a strange error with the following bit of code. All of the variables are double precision.
preWinT = .20;info.micFsr2 =2000;T360_wrong = (preWinT-.02)*info.micFsr2info.micFsr3 =20000;T3600_correct = (preWinT-.02)*info.micFsr3
Notice the trailing "1" in T360_wrong in the output that follows:
T360_wrong = 3.600000000000001e+02
When increasing the multiplier from 2000 to 20000, the error does not appear.
T3600_correct = 3.600000000000000e+03
This is even happening when entering purely numeric values in the command window.
(.2-.02)*2000 ans = 3.600000000000001e+02
The error again disappears when I enter
(.18)*2000 ans = 360
Does anyone have any idea why this is happening? It's pretty disturbing to think about the ramifications of this kind of error.
Thanks,
David
Best Answer