What is Double.isInfinite in Swift?
Overview
Double.isInfinte is used to indicate if a value of type double is infinite or not.
Syntax
Double.isInfinite
Parameter
This function does not take any parameter.
Return value
The value returned is a boolean value. It returns true if the value is infinite. Otherwise, it returns false.
Code example
// create some double valueslet d1 = 1.233let d2 = Double.infinitylet d3 = 0.9let d4 = Double.infinity/0// check if infinityprint(d1.isInfinite)print(d2.isInfinite)print(d3.isInfinite)print(d4.isInfinite)
Explanation
- Lines 2-5: We create some double values.
- Lines 8-11: We check if the double values we created are infinite and print the results.