NSDecimalNumber(x).intValue returns -2, 0, 15 and 199, depending on the amount of decimals in x (x = 199.999…5)
问题 We found an interesting case in our business logic that totally breaks our logic and we don't understand why NSDecimalNumber and Decimal behaves the way it does. My playground for the cases is as follows: import Foundation let pQuantity = Decimal(string: "0.2857142857142857")! let pPrice = Decimal(string: "7.00000000000000035")! let calced = NSDecimalNumber(decimal: pQuantity * pPrice * Decimal(integerLiteral: 100)) // 200 let decimal = calced.decimalValue // 199