Hello
I'm making an app that displays large Double numbers, for example 86,859.002. The problem is how do I change the comma( , ) with the dot ( . )
Thank you
I'm making an app that displays large Double numbers, for example 86,859.002. The problem is how do I change the comma( , ) with the dot ( . )
Thank you
When you show numeric values for users, you use NumberFormatter:
You usually set an appropriate Locale instead of specifying thousandSeparator explicitly.
An example.
Code Block let value: Double = 86_859.002 let nf = NumberFormatter() nf.numberStyle = .decimal nf.thousandSeparator = "." nf.decimalSeparator = "," nf.maximumFractionDigits = 3 print(nf.string(from: value as NSNumber) ?? "") //->86.859,002
You usually set an appropriate Locale instead of specifying thousandSeparator explicitly.
An example.
Code Block let nfEs = NumberFormatter() nfEs.numberStyle = .decimal nfEs.locale = Locale(identifier: "es_ES") nfEs.maximumFractionDigits = 3 print(nfEs.string(from: value as NSNumber) ?? "") //->86.859,002