<!--
{
  "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/towardZero",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s25FloatingPointRoundingRuleO10towardZeroyA2BmF"
  },
  "title" : "FloatingPointRoundingRule.towardZero"
}
-->

# FloatingPointRoundingRule.towardZero

Round to the closest allowed value whose magnitude is less than or equal
to that of the source.

```
case towardZero
```

## Discussion

The following example shows the results of rounding numbers using this
rule:

```
(5.2).rounded(.towardZero)
// 5.0
(5.5).rounded(.towardZero)
// 5.0
(-5.2).rounded(.towardZero)
// -5.0
(-5.5).rounded(.towardZero)
// -5.0
```

This rule is equivalent to the C `trunc` function and implements the
`roundToIntegralTowardZero` 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)