Convert String to Decimal number it remove points before zeros in Swift 4
问题 Please check this example let strValue = "12.00" let decimalValue = Decimal(string: strValue) // 12 it always returns 12 not 12.00 I also try with NSNumber , Float , and Double but it always remove zeros. Can you please help me with this thanks in advance 回答1: Like martin said. 12 and 12.00 is the same number. It doesn't mathematical matter how many 0 are behind the comma. While a number stays the same, the representation is a different topic. String(format: "%.6f", 12) will give 12.000000 as