Handle Floating point rounding errors, efficiently
Don't know about the fastest, most efficient, but
Const dEPSILON As Double = 1E-10 'set appropriately
If Abs(Cells(21, 1).Value - 1) < dEPSILON Then ...
will work. Using Range references (Cells(21,1)) instead of the evaluate
method ([A21]) will likely speed up your code more than which method of
testing you use.
In article ,
"Peter T" <peter_t@discussions wrote:
The various methods I've tried to eliminate "false" results slow the process
at least to some extent, inevitably I suppose. My purpose and the point of
this post is to do exactly what you suggest:
"design your programs to be tolerant of the approximations inherent in
floating point numbers"
But in the fastest most efficient way possible.
|