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

# rounded(rule:increment:)

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

## Declaration

```swift
func rounded(rule: FloatingPointFormatStyle<Value>.Configuration.RoundingRule = .toNearestOrEven, increment: Double? = nil) -> FloatingPointFormatStyle<Value>
```

## 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 floating-point format style modified to use the specified rounding rule and increment.

## Discussion

Discussion The following example creates a default FloatingPointFormatStyle for the en_US locale, and modifies its rounding behavior. It uses the FloatingPointRoundingRule.up rounding rule, and an increment of 0.25. It then applies this style to an array of floating-point values, rounding them to the next greater increment of 0.25. let roundedStyle = FloatingPointFormatStyle<Double>(locale: Locale(identifier: "en_US"))     .rounded(rule: .up, increment: 0.25) let nums = [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6] let roundedNums = nums.map { roundedStyle.format($0) } // ["1.00", "1.25", "1.25", "1.50", "1.50", "1.50", "1.75"]

## See Also

### Customizing style behavior

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