Mike D Mike D - 1 year ago 93
Swift Question

Swift how to format a large number with thousands seperators?

Is there a simple command to format 1.60543e+06 to 1,605,436???

resultFV.text = String.localizedStringWithFormat("%f", fv)

does not get it.

Answer Source

Swift xCode 6.3 , SOLVED ( I decided to lease the $ in): code If desire no $ in output, change .CurrencyStyle to .DecimalStyle

var fv = 3534234.55 
var formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
formatter.maximumFractionDigits = 0;
resultFV.text = formatter.stringFromNumber(fv) // result: $3,534,235 –
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download