Instance Property

maximumFractionDigits

The maximum number of digits after the decimal separator.

Declaration

@property NSUInteger maximumFractionDigits;

Discussion

By default, this property is set to 0.

The following code demonstrates the effect of setting maximumFractionDigits when formatting a number:

var numberFormatter = NumberFormatter()

numberFormatter.maximumFractionDigits = 0 // default
numberFormatter.string(from: 123.456) // 123

numberFormatter.maximumFractionDigits = 3
numberFormatter.string(from: 123.456789) // 123.457

See Also

Configuring Integer and Fraction Digits

minimumIntegerDigits

The minimum number of digits before the decimal separator.

maximumIntegerDigits

The maximum number of digits before the decimal separator.

minimumFractionDigits

The minimum number of digits after the decimal separator.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software