0

Example:

import UIKit

let amountDecimal:NSDecimalNumber = 22.99

let amount = amountDecimal.doubleValue

Expected: 22.99

Return: 22.990000000000002

  • The solution is NOT to use a floating point literal or a Double when initializing your decimal type. `Decimal(sign: .plus, exponent: -2, significand: 2299)` or `Decimal(string: "22.99")!`. Note that `Double` type will always have this behavior. – Leo Dabus Sep 21 '22 at 21:06

0 Answers0