You almost never want to write code like the following:

```
double x;
double y;
...
if (x == y) {...}
```

Most **floating point** operations involve at least a tiny loss of precision. Even if two numbers are equal for all practical purposes, they may not be exactly equal down to the last bit, and so the equality test is likely to fail.

For example, the following code snippet prints -1.77635683940025E-15. Although in theory, squaring should undo a square root, the round-trip operation is slightly inaccurate.

```
double x = 10;
double y = System.Math.Sqrt(x);
y *= y;
if (x == y)
Rhino.RhinoApp.WriteLine("Square root is exact");
else
Rhino.RhinoApp.WriteLine("{0}", x-y);
```

In most cases, the equality test above should be written as something like the following:

```
double tolerance = ...
if (System.Math.Abs(x - y) < tolerance) {...}
```

Here, tolerance is some threshold that defines what is *close enough* for equality. This begs the question of how close is close enough. This cannot be answered in the abstract; you have to know something about your particular problem to know how close is close enough in your context.