minimumSignificantDigits
The minimum number of significant digits for the number formatter.
Declaration
var minimumSignificantDigits: Int { get set }Discussion
You must set the usesSignificantDigits property to true in order for this property to affect formatting behavior. By default, the minimum number of significant digits is 1.
The following code demonstrates the effect of setting minimumSignificantDigits when formatting various numbers:
var numberFormatter = NumberFormatter()
numberFormatter.usesSignificantDigits = true
numberFormatter.minimumSignificantDigits = 4
numberFormatter.string(from: 123) // 123.0
numberFormatter.string(from: 123.45) // 123.45
numberFormatter.string(from: 100.23) // 100.23
numberFormatter.string(from: 1.2300) // 1.230
numberFormatter.string(from: 0.000123) // 0.0001230