Thanks for the temp workaround. Just a heads up - that code has a bug when the number is negative.
(-1.5).roundedDecimal(scale: 1) // returns 1.5
The fix is to wrap self in abs(self).
extension Double {
func roundedDecimal(scale: Int = 0, rule: FloatingPointRoundingRule = .toNearestOrEven) -> Decimal {
let significand = Decimal((abs(self) * pow(10, Double(scale))).rounded(rule))
return Decimal(sign: self.sign, exponent: -scale, significand: significand)
}
}
Post
Replies
Boosts
Views
Activity
That did nothing for me - same error messages persist.