如果计算结果不是无限的,我如何签入Swift?
我下面的代码在打印“dividepointsbyrest是inf”之后崩溃了。如果除法点被checks != 0“检查为零。‘如果除以does != inf’不起作用。
var dividepointsbyrest = (BPMpoints / restDouble)
print("dividepointsbyrest is")
print(dividepointsbyrest)
var BPMpercentD = 100.0 * dividepointsbyrest发布于 2016-11-01 15:40:50
Double有一个isInfinite/isFinite属性。
if dividepointsbyrest.isInfinite {
print("dividepointsbyrest is infinite")
}或
if dividepointsbyrest.isFinite {
print("dividepointsbyrest is finite")
}https://stackoverflow.com/questions/40363385
复制相似问题