<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/FloatingPointRoundingRule/toNearestOrEven",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s25FloatingPointRoundingRuleO15toNearestOrEvenyA2BmF"
  },
  "title" : "FloatingPointRoundingRule.toNearestOrEven"
}
-->

# FloatingPointRoundingRule.toNearestOrEven

Round to the closest allowed value; if two values are equally close, the
even one is chosen.

```
case toNearestOrEven
```

## Discussion

This rounding rule is also known as “bankers rounding,” and is the
default IEEE 754 rounding mode for arithmetic. The following example
shows the results of rounding numbers using this rule:

```
(5.2).rounded(.toNearestOrEven)
// 5.0
(5.5).rounded(.toNearestOrEven)
// 6.0
(4.5).rounded(.toNearestOrEven)
// 4.0
```

This rule implements the `roundToIntegralTiesToEven` operation defined by
the [IEEE 754 specification](http://ieeexplore.ieee.org/servlet/opac?punumber=4610933).

---

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)