I'm not familiar with Swift but as a general rule in any language, double values should not be compared using equality operator. Instead two double values should be considered equal if their absolute arithmetic difference is small than an epsilon
var epsilon = 0.00000001;
if(fabs(v1-v2)< epsilon){ // values are considered equal
}