I should also point out:
(a) your code can be somewhat simpler in Swift. I would probably write
something along the lines of:
func almostEqual<T: FloatingPoint>(_ a: T, _ b: T) -> Bool {
return a >= b.nextDown && a <= b.nextUp
}
(b) one ULP is almost never a tolerance you want to use. It’s much too small
for almost all computations, and too large for most of the remaining ones.
– Steve
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users