<p>I have trouble comparing 2 double in Excel VBA</p>

<p>suppose that I have the following code</p>

<pre><code>Dim a as double
Dim b as double
a = 0.15
b = 0.01
</code></pre>

<p>After a few manipulations on b, b is now equal to 0.6</p>

<p>however the imprecision related to the double data type gives me headache because</p>

<pre><code>if a = b then
 //this will never trigger
end if
</code></pre>

<p>Do you know how I can remove the trailing imprecision on the double type?</p>

It is never wise to compare doubles on equality.
Some decimal values map to several floating point representations. So one 0.6 is not always equal to the other 0.6.
If we subtract one from the other, we probably get something like 0.00000000051.
We can now define equality as having a difference smaller that a certain error margin.