The general wisdom when comparing
floating-point values is to see if they are within some
small range of each other (called a delta, or tolerance).
You have to decide how small a delta is important to you.
Code to do this looks something like the following:
delta = 0.00001 # for example
difference = abs(a) - abs(b) # subtract the two
values
if (difference < delta)
# all ok
else
# not ok
--------------------------------------------------------------
If the desired value, a is -1000, and b
is +1000, the answer is off by 2000. But difference
will be zero.
Thanks for all of your work,
Ricky