Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the smallest possible Float in Swift

I want to find, programmatically, and portably, the smallest Float possible.

By smallest I mean the smallest > 0 Float. Any way to achieve that ?

like image 230
Antzi Avatar asked Mar 06 '23 20:03

Antzi


1 Answers

Looking up the documentation for Float I found: Float.leastNonzeroMagnitude

The least positive number.

This value compares less than or equal to all positive numbers, but greater than zero. If the type supports subnormal values, leastNonzeroMagnitude is smaller than leastNormalMagnitude; otherwise they are equal.

like image 104
Antzi Avatar answered Mar 08 '23 09:03

Antzi