当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - How to convert the exponential value to normal decimal or without exponent format in swift

问题描述:

I am getting a exponential value for the expected downloadable size in NSURLConnectionDelegate.

its showing as 1.34597e+08

Now I am trying to convert the value to 1.3459 using the below code but with no luck

 self.expectedDownloadSize = Float(response.expectedContentLength)

let s = self.expectedDownloadSize.description

let numberFormatter = NSNumberFormatter()

numberFormatter.numberStyle = NSNumberFormatterStyle.DecimalStyle

numberFormatter.maximumFractionDigits = 4

var num = numberFormatter.numberFromString(s as String)

self.expectedDownloadSize = num?.floatValue

Please help me getting the expected size of download.

分享给朋友:
您可能感兴趣的文章:
随机阅读: