I want to format the number according to there digit base, like if I pass the number like 29000 then the number should be converted as 29 K and if passed number is 290000.. the converted number should be 2.9 M/B/ or something else according to digit, currently im using the following way
func formatNumber (number: Double) -> String? {
let formatter = NSNumberFormatter()
formatter.maximumFractionDigits = 1
return formattedNumberString?.stringByReplacingOccurrencesOfString(".00", withString: "")
and for use :
let lblValue = Double(2500)/1000
lbl.text = "\(formatNumber(lblValue)!)K"
but it is only work for given subscript not for all and automatically