swift3 判断两个浮点数相等

let progress:CGFloat = 1
([1.00000001, 1.000, 1, 0.9999999991, 0.999998, 0.99] as [CGFloat]) .forEach { (s) in
    if s == progress {
        print("相等 \(s) == 1")
    }
}

let progress2:Float = 1
([1.00000001, 1.000, 1, 0.9999999991, 0.999998, 0.99] as [Float]) .forEach { (s) in
    if s == progress2 {
        print("相等 \(s) == 1")
    }
}



**相等**** 1.0 == 1**
**相等**** 1.0 == 1**
**相等**** 1.0 == 1**
**相等**** 1.0 == 1**
**相等**** 1.0 == 1**
**相等**** 1.0 == 1**

你可能感兴趣的:(swift3 判断两个浮点数相等)