<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NumberFormatStyleConfiguration/Precision/integerAndFractionLength(integerLimits:fractionLimits:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation30NumberFormatStyleConfigurationO9PrecisionV24integerAndFractionLength0G6Limits08fractionK0AEx_q_tSXRzSXR_Si5BoundRtzSiAIRt_r0_lFZ"
  },
  "title" : "integerAndFractionLength(integerLimits:fractionLimits:)"
}
-->

# integerAndFractionLength(integerLimits:fractionLimits:)

Returns a precision that constrains formatted values to ranges of allowed digits in the integer and fraction parts.

```
static func integerAndFractionLength<R1, R2>(integerLimits: R1, fractionLimits: R2) -> NumberFormatStyleConfiguration.Precision where R1 : RangeExpression, R2 : RangeExpression, R1.Bound == Int, R2.Bound == Int
```

## 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.

## Return Value

A precision that constrains formatted values to ranges of digits in the integer and fraction parts.

## Discussion

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"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)