Example1:
let num = NSDecimalNumber(string: "0.123456789012345678909")
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.usesGroupingSeparator = true
formatter.maximumFractionDigits = 25
formatter.minimumFractionDigits = 25
formatter.minimumIntegerDigits = 1
let str = formatter.string(from: num) ?? ""
print(str)
output
"0.1234567890123460000000000"
Example2:
let num = NSDecimalNumber(string: "12323.123456789012345678909")
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.usesGroupingSeparator = true
formatter.maximumFractionDigits = 25
formatter.minimumFractionDigits = 25
formatter.minimumIntegerDigits = 1
let str = formatter.string(from: num) ?? ""
print(str)
output
"12,323.1234567890000000000000000"
How to correctly format the contents of the above two inputs?