# Renewing \`Foundation.Decimal\`

**URL:** <https://forums.swift.org/t/renewing-foundation-decimal/89713>\
**Category:** Foundation\
**Tags:** decimal\
**Created:** [September 23, 2026, 2:21am UTC](https://forums.swift.org/t/renewing-foundation-decimal/89713 "2026-09-23T02:21:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [September 23, 2026, 2:21am UTC](https://forums.swift.org/t/renewing-foundation-decimal/89713/1 "2026-09-23T02:21:35Z")

</div>

Hi all,

Admittedly, the `Foundation.Decimal` type is the product of another time. It doesn't represent infinity or negative zero, for example, characteristics that are decidedly unlike those of standard IEEE types and that preclude conformance to the standard library's `FloatingPoint` protocol. We probably wouldn't design a decimal floating-point type from scratch today in a similar way. Still, this is the decimal floating-point type that Swift has today (now cross-platform!), and it continues to see active use. I'm excited to share some recent work that's shown how much better `Foundation.Decimal` can be on its own terms.

To set the table, @hassila [announced](https://forums.swift.org/t/fixedpointdecimal-exact-decimal-arithmetic-50x-1000x-faster-than-foundation-decimal/85642) this past spring that Ordo One contributed a fix to `swift-foundation` removing heap allocations for a 3–5× improvement in performance—hugely inspiring. Still, the type was a long ways away from performing in the same ballpark as fixed-point decimal types. Was the gap entirely because floating-point math is just _that_ much more costly, or could we close the gap still further?

As it turns out, even without dynamic allocations, the `swift-foundation` implementation for `Decimal` performed many operations one 16-bit limb at a time. By using 128-bit integer primitives instead and some other not-too-fancy optimizations, two successive PRs ([1](https://github.com/swiftlang/swift-foundation/pull/2022), [2](https://github.com/swiftlang/swift-foundation/pull/2131)) combine with the existing Ordo One contribution to improve performance by a cumulative **15–40×** in benchmarks from the prior baseline (when shipped in a future toolchain—not in 6.4). What's more, a number of issues with correct rounding and loss of precision have been addressed: arithmetic that previously ignored the requested rounding mode now honors it, and `NSDecimal*` APIs now more consistently report loss of precision for inexact results. (And the two PRs do this with close to zero net change in production lines of code.)

With users now able to depend on certain API guarantees that were previously vacuous, these implementation-level changes actually bring to the foreground some API-level tweaks which I think probably ought to roll out in tandem. For that reason, I'll be assembling an initial bundle of (probably rather niche) changes to pitch shortly. Hopefully, interested parties will come forward and chime in on whether that pitch hits the right notes.

For the moment, though, I hope folks using the `Foundation.Decimal` type will find these improvements to be as delightful to use as I found them to implement!

Xiaodi

---

<div class="post-metadata">

**Author:** ![hassila](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hassila/32/22647_2.png) [@hassila](https://forums.swift.org/u/hassila)\
**Post date:** [September 23, 2026, 2:26am UTC](https://forums.swift.org/t/renewing-foundation-decimal/89713/2 "2026-09-23T02:26:52Z")

</div>

Thanks @xwu !

I followed your work with great interest, very happy to see the end result landing now — it definitely makes a huge difference making decimal much more useful for a wider range of applications- nice work!

Joakim

---

<div class="post-metadata">

**Author:** ![Tony\_Parker](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tony_parker/32/273_2.png) [@Tony\_Parker](https://forums.swift.org/u/Tony_Parker)\
**Post date:** [September 23, 2026, 5:44am UTC](https://forums.swift.org/t/renewing-foundation-decimal/89713/3 "2026-09-23T05:44:52Z")

</div>

Awesome work @xwu !

---

<div class="post-metadata">

**Author:** ![blindspotbounty](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/blindspotbounty/32/44760_2.png) [@blindspotbounty](https://forums.swift.org/u/blindspotbounty)\
**Post date:** [September 23, 2026, 9:32am UTC](https://forums.swift.org/t/renewing-foundation-decimal/89713/4 "2026-09-23T09:32:04Z")

</div>

Thanks @xwu !

---

<div class="post-metadata">

**Author:** ![maciejtrybilo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/maciejtrybilo/32/32193_2.png) [@maciejtrybilo](https://forums.swift.org/u/maciejtrybilo)\
**Post date:** [September 29, 2026, 6:18pm UTC](https://forums.swift.org/t/renewing-foundation-decimal/89713/5 "2026-09-29T18:18:24Z")

</div>

It's great to see Decimal getting some love. For web based apps that need to handle financial data it has been remarkably slow. This will help a lot!
