let a = Float(1.0) - Float(0.9)
print("a = ",a)
let b = Float(0.9) - Float(0.8)
print("b = ",b)
if(a == b){
print("true")
} else {
print("false")
}
print("-------------")
let c = Decimal(1.0) - Decimal(0.9)
print("c = ",c)
let d = Decimal(0.9) - Decimal(0.8)
print("d = ",d)
if(c == d){
print("true")
} else {
print("false")
}
log 输出
a = 0.100000024
b = 0.099999964
false
-------------
c = 0.1
d = 0.1
true
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)