# Decimal has no rounded()

**URL:** <https://forums.swift.org/t/decimal-has-no-rounded/14200>\
**Category:** Using Swift\
**Tags:** foundation\
**Created:** [July 3, 2018, 12:39pm UTC](https://forums.swift.org/t/decimal-has-no-rounded/14200 "2018-07-03T12:39:23Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![LinusU](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/linusu/32/3093_2.png) [@LinusU](https://forums.swift.org/u/LinusU)\
**Post date:** [June 13, 2019, 11:12am UTC](https://forums.swift.org/t/decimal-has-no-rounded/14200/12 "2019-06-13T11:12:18Z")

</div>

If anyone else is interested in solving this in the short term, this is the extension that I used in a project I'm currently working on:

```swift
extension Decimal {
    mutating func round(_ scale: Int, _ roundingMode: NSDecimalNumber.RoundingMode) {
        var localCopy = self
        NSDecimalRound(&self, &localCopy, scale, roundingMode)
    }

    func rounded(_ scale: Int, _ roundingMode: NSDecimalNumber.RoundingMode) -> Decimal {
        var result = Decimal()
        var localCopy = self
        NSDecimalRound(&result, &localCopy, scale, roundingMode)
        return result
    }
}

```

---

_[View the full topic](https://forums.swift.org/t/decimal-has-no-rounded/14200)._
