How to check for inf? Swift xcode7

How to check Swift if the calculation result is not infinite?

My code below is reset after printing that "dividepointsbyrest is inf". "If dividepointsbyrest! = Nil" checks for nil. "If dividepointsbyrest! = Inf 'does not work.

var dividepointsbyrest = (BPMpoints / restDouble)
    print("dividepointsbyrest is") 
    print(dividepointsbyrest) 

    var BPMpercentD = 100.0 * dividepointsbyrest
+4
source share
1 answer

Doublehas for this property isInfinite/ isFinite.

if dividepointsbyrest.isInfinite {
    print("dividepointsbyrest is infinite")
}

or

if dividepointsbyrest.isFinite {
    print("dividepointsbyrest is finite")
}
+12
source

Source: https://habr.com/ru/post/1659536/


All Articles