What is the Double.nextDown property of a double value in Swift?
Overview
The Double.nextDown property of a double value in Swift finds the greatest representable value that compares less than this value.
Syntax
Double.nextDown
Return value
This property returns the greatest representable value that compares less than the double value.
Code example
// Create some double valueslet d1 = 2.3let d2 = 0.0let d3 = Double.infinitylet d4 = Double.nanlet d5 = -0.1// Get the nextDown property valuesprint(d1.nextDown)print(d2.nextDown)print(d3.nextDown)print(d4.nextDown)print(d5.nextDown)
Explanation
- Lines 2 to 6: We create some double values.
- Line 9 to 13: We get the
nextDownproperty of theDoubleinstance values, and print them to the console.