user7845351 user7845351 -4 years ago 120
Swift Question

How to conver Long Double to String in swift

i would like to print data Double in swift, but output alwas 4.444444444444e+24 not real number. Can you tell me how do that?

Answer Source

@Skytect's answer is almost correct. It is just missing one step. Try the following code

let data1 : Double = 44444444444444444.0
let data2 : Double = 1000000.0
let data3 = data1 * data2

let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
let num = NSNumber(value: data3)
let finalNumber = numberFormatter.string(from: num)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download