Same as comparing floating point numbers in any other language.
Take the absolute value of the difference of numbers and compare it with your acceptable delta.
let delta: CGFloat = 0.00001 let a: CGFloat = 3.141592 let b: CGFloat = 3.141593 if abs(ab) < delta { println("close enough for government work") }
nhgrif
source share