Search code examples
operator-keywordinequality

VB Inequality Operator False Result


I have some problems with the inequality operators.

Consider the code below:

If a >= 0.00000001 Then
            ' action statement
End If

a variable is a Single and a = 0.00000001.

When I run the if condition using Microsoft Visual Basic 2010 Express, the Immediate Windows says it is false. I have inserted a screenshot for your reference. Screenshot

Do you know what is the root cause of this issue and how do I solve it?

Thank you


Solution

  • Floating-point math is not exact. It's an approximation.

    There's more to it here: http://floating-point-gui.de/