Take a hypothetical Aircraft class that has two properties; Altitude and AltitudeChange:

```
public class Aircraft  
{
    public double Altitude { get; set; }
    public AltitudeChange { get; set; }
}

```

And Altitude change has two properties; Altitude and RateOfClimb:

```
public class AltitudeChange
{ 
    public double Altitude { get; set; }
    public double RateOfClimb { get; set; } //Negative for descent
}

```

If we have a 'Worker Thread' that updates the Aircraft's altitude based on the time ellapsed and the Rate of Climb, what's the ideal design/implementation to ensure the loop stops when the new Altitude is hit?

```
private void AltitudeThreadWork()
{
    var updated = DateTime.Now;

    while (Aircraft.Altitude != AltitudeChange.Altitude)
    {
        UpdateAltitude((DateTime.Now - updated).TotalMilliseconds);
        updated = DateTime.Now;
        Thread.Sleep(40);
    }
}

private void UpdateAltitude(double ellapsed)
{
    Aircraft.Altitude += ellapsed*(AltitudeChange.RateOfClimb/60000d);
}

```

For example, this thread does't stop the climbing process because the double precision numbers are often not going to exactly equal each other. 

Even if you cast the double to an int, you still can't be 100% sure that the two values will equal.