Instance Property インスタンスプロパティ

maximumSignificantDigits

The maximum number of significant digits for the number formatter. 数値フォーマッタに対する最大の有効桁数。

Declaration 宣言

@property NSUInteger maximumSignificantDigits;

Discussion 議論

You must set the usesSignificantDigits property to YES in order for this property to affect formatting behavior. By default, the maximum number of significant digits is 6. Values less than 1 are ignored. あなたは、usesSignificantDigitsプロパティをYESに設定しなければなりません、このプロパティが書式設定挙動に影響を及ぼすために。初期状態では、最大限の有効桁数は6です。1より少ない値は、無視されます。

The following code demonstrates the effect of setting maximumSignificantDigits when formatting various numbers: 以下のコードは、maximumSignificantDigitsを様々な数値を書式設定している時に設定する効果を実演します:


var numberFormatter = NumberFormatter()
numberFormatter.usesSignificantDigits = true
numberFormatter.maximumSignificantDigits = 4


numberFormatter.string(from: 12345) // 12340
numberFormatter.string(from: 123.456) // 123.5
numberFormatter.string(from: 100.234) // 100.2
numberFormatter.string(from: 1.230) // 1.23
numberFormatter.string(from: 0.00012345) // 0.0001234

See Also 参照

Configuring Significant Digits 有効桁数を構成設定する