Is there any way to get the maximum number of type Double in Swift? The number such that anyDoubleNumber < theNumber
will always be true.
2 Answers
I have found the solution to my own question.
var theNumber = Double.infinity
Should do the work. :)
Double.infinity
addresses the original problem of ensuring that anyDoubleNumber < theNumber
is always true but there is also Double.greatestFiniteMagnitude
which is more consistent with the other numerical types (like Int.max
).
Infinity is a fairly special case specific to floating point math.