The minimum() method returns the minimum of the given two values.
Example
minimum() Syntax
The syntax of the double minimum() method is:
double.minimum(firstValue, secondValue)
Here, double is an object of the Double class.
minimum() Parameters
The minimum() method takes two parameters
firstValue- a floating point valuesecondValue- another floating point value
minimum() Return Values
- returns the minimum element between
firstValueandsecondValue
Example 1: Swift Double minimum()
Output
10.0 20.8 60.0
In the above example, we have used the minimum() method find the smallest among two provided floating point numbers.
Example 2: Swift Double and NaN (Not a Number)
Output
10.0 nan
Here, if we pass .nan as one of the parameters, the method will return the other value.
And, if we pass .nan for both the parameters, the method will return nan.