---
title: "rounded(rule:increment:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/decimal/formatstyle/rounded(rule:increment:)"
---

# rounded(rule:increment:)

Modifies the format style to use the specified rounding rule and increment.

## Declaration

```swift
func rounded(rule: Decimal.FormatStyle.Configuration.RoundingRule = .toNearestOrEven, increment: Int? = nil) -> Decimal.FormatStyle
```

## Parameters

- `rule`: The rounding rule to apply to the format style.
- `increment`: A multiple by which the formatter rounds the fractional part. The formatter produces a value that is an even multiple of this increment. If this parameter is nil (the default), the formatter doesn’t apply an increment.

## Return Value

Return Value A decimal format style modified to use the specified rounding rule and increment.

## Discussion

Discussion The following example creates a default Decimal.FormatStyle for the en_US locale, and a modified style that rounds integers to the nearest multiple of 100. It then formats the value 1999.95 using these format styles. let defaultStyle = Decimal.FormatStyle(locale: Locale(identifier: "en_US")) let roundedStyle = defaultStyle.rounded(rule: .toNearestOrEven,                                         increment: 100) let num: Decimal = 1999.95 let defaultNum = num.formatted(defaultStyle) // "1,999.95" let roundedNum = num.formatted(roundedStyle) // "2,000"

## See Also

### Customizing style behavior

- [decimalSeparator(strategy:)](foundation/decimal/formatstyle/decimalseparator(strategy:).md)
- [grouping(_:)](foundation/decimal/formatstyle/grouping(_:).md)
- [locale(_:)](foundation/decimal/formatstyle/locale(_:).md)
- [notation(_:)](foundation/decimal/formatstyle/notation(_:).md)
- [precision(_:)](foundation/decimal/formatstyle/precision(_:).md)
- [scale(_:)](foundation/decimal/formatstyle/scale(_:).md)
- [sign(strategy:)](foundation/decimal/formatstyle/sign(strategy:).md)
- [Decimal.FormatStyle.Configuration](foundation/decimal/formatstyle/configuration.md)
- [NumberFormatStyleConfiguration](foundation/numberformatstyleconfiguration.md)
