One Logo Pool Ball
Foundation · IOS API REFERENCE

NumberFormatStyleConfiguration.Precision

struct · iOS 15.0+ · SDK 27.1

struct Precision

A structure that an integer format style uses to configure precision.

Members (7)

static · iOS 15.0+

integerLength

TypeScript
static integerLength(length: number): NumberFormatStyleConfiguration_Precision
Swift declaration
static func integerLength(_ length: Int) -> NumberFormatStyleConfiguration.Precision

Returns a precision that constrains formatted values to a given number of allowed digits in the integer part. - Parameter length: The number of digits to use when formatting the integer part of a number. - Returns: A precision that constrains formatted values to a given number of allowed digits in the integer part.

static · iOS 15.0+

fractionLength

TypeScript
static fractionLength(length: number): NumberFormatStyleConfiguration_Precision
Swift declaration
static func fractionLength(_ length: Int) -> NumberFormatStyleConfiguration.Precision

Returns a precision that constrains formatted values to a given number of allowed digits in the fraction part. - Parameter length: The number of digits to use when formatting the fraction part of a number. - Returns: A precision that constrains formatted values to a given number of allowed digits in the fraction part.

static · iOS 15.0+

fractionLength

TypeScript
static fractionLength10948(limits: SDKHandle): NumberFormatStyleConfiguration_Precision
Swift declaration
static func fractionLength<R>(_ limits: R) -> NumberFormatStyleConfiguration.Precision where R : RangeExpression, R.Bound == Int

Returns a precision that constrains formatted values to a range of allowed digits in the fraction part. - Parameter limits: A range from the minimum to the maximum number of digits to use when formatting the fraction part of a number. - Returns: A precision that constrains formatted values to a range of allowed digits in the fraction part.

static · iOS 15.0+

significantDigits

TypeScript
static significantDigits(digits: number): NumberFormatStyleConfiguration_Precision
Swift declaration
static func significantDigits(_ digits: Int) -> NumberFormatStyleConfiguration.Precision

Returns a precision that constrains formatted values to a given number of significant digits. When using this precision, the formatter rounds values that have more significant digits than the maximum of the range, as seen in the following example: ```swift let myNum = 123456.formatted(.number .precision(.significantDigits(4)) .rounded(rule: .down)) // "123,400" ``` - Parameter digits: The maximum number of significant digits to use when formatting values. - Returns: A precision that constrains formatted values to a given number of significant digits.

static · iOS 15.0+

significantDigits

TypeScript
static significantDigits59270(limits: SDKHandle): NumberFormatStyleConfiguration_Precision
Swift declaration
static func significantDigits<R>(_ limits: R) -> NumberFormatStyleConfiguration.Precision where R : RangeExpression, R.Bound == Int

Returns a precision that constrains formatted values to a range of significant digits. When using this precision, the formatter rounds values that have more significant digits than the maximum of the range, as seen in the following example: ```swift let myNum = 123456.formatted(.number .precision(.significantDigits(2...4)) .rounded(rule: .down)) // "123,400" ``` - Parameter limits: A range from the minimum to the maximum number of significant digits to use when formatting values. - Returns: A precision that constrains formatted values to a range of significant digits.

static · iOS 15.0+

integerAndFractionLength

TypeScript
static integerAndFractionLengthIntegerFraction(integer: number, fraction: number): NumberFormatStyleConfiguration_Precision
Swift declaration
static func integerAndFractionLength(integer: Int, fraction: Int) -> NumberFormatStyleConfiguration.Precision

Returns a precision that constrains formatted values a given number of allowed digits in the integer and fraction parts. When using this precision, the formatter pads values with fewer digits than the specified digits for the integer or fraction parts. Similarly, it rounds values that have more digits than specified. The following example shows this behavior, padding the integer part while rounding the fraction: ```swift let myNum = 12345.6789.formatted(.number .precision(.integerAndFractionLength(integer: 6, fraction: 3)) .rounded(rule: .down)) // "012,345.678" ``` - Parameters: - integer: The number of digits to use when formatting the integer part of a number. - fraction: The number of digits to use when formatting the fraction part of a number. - Returns: A precision that constrains formatted values a given number of digits in the integer and fraction parts.

static · iOS 15.0+

integerAndFractionLength

TypeScript
static integerAndFractionLengthIntegerLimitsFractionLimits(integerLimits: SDKHandle, fractionLimits: SDKHandle): NumberFormatStyleConfiguration_Precision
Swift declaration
static func integerAndFractionLength<R1, R2>(integerLimits: R1, fractionLimits: R2) -> NumberFormatStyleConfiguration.Precision where R1 : RangeExpression, R2 : RangeExpression, R1.Bound == Int, R2.Bound == Int

Returns a precision that constrains formatted values to ranges of allowed digits in the integer and fraction parts. When using this precision, the formatter rounds values that have more digits than the maximum of the range, as seen in the following example: ```swift let myNum = 12345.6789.formatted(.number .precision(.integerAndFractionLength(integerLimits: 2..., fractionLimits: 2...3)) .rounded(rule: .down)) // "12,345.678" ``` - Parameters: - integerLimits: A range from the minimum to the maximum number of digits to use when formatting the integer part of a number. - fractionLimits: A range from the minimum to the maximum number of digits to use when formatting the fraction part of a number. - Returns: A precision that constrains formatted values to ranges of digits in the integer and fraction parts.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

NumberFormatStyleConfiguration.Precision.integerLength(_:)

This declaration needs Swift generic type arguments. (no canonical witness for R)

All Foundation types →