---
title: FloatingPointRoundingRule.toNearestOrAwayFromZero
framework: swift
role: symbol
role_heading: Case
path: swift/floatingpointroundingrule/tonearestorawayfromzero
---

# FloatingPointRoundingRule.toNearestOrAwayFromZero

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

## Declaration

```swift
case toNearestOrAwayFromZero
```

## Discussion

Discussion This rounding rule is also known as “schoolbook rounding.” The following example shows the results of rounding numbers using this rule: (5.2).rounded(.toNearestOrAwayFromZero) // 5.0 (5.5).rounded(.toNearestOrAwayFromZero) // 6.0 (-5.2).rounded(.toNearestOrAwayFromZero) // -5.0 (-5.5).rounded(.toNearestOrAwayFromZero) // -6.0 This rule is equivalent to the C round function and implements the roundToIntegralTiesToAway operation defined by the IEEE 754 specification.
