When we want to check if an object of type double is finite or infinite, we can use the Double.isFinite
property.
Double.isFinite
The value returned is a boolean value. We get true
if Double
is a finite value. Otherwise, we get false
.
// create some double valueslet d1 = 12.44let d2 = Double.infinitylet d3 = Double.infinity / 0.4let d4 = 0.1// print the exponentsprint(d1.isFinite)print(d2.isFinite)print(d3.isFinite)print(d4.isFinite)