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 values let d1 = 12.44 let d2 = Double.infinity let d3 = Double.infinity / 0.4 let d4 = 0.1 // print the exponents print(d1.isFinite) print(d2.isFinite) print(d3.isFinite) print(d4.isFinite)
RELATED TAGS
CONTRIBUTOR
View all Courses