Conversion to string types from Double and Float in Swift
Forums:
let exp = 2.718_281_828
let s1 = "\(exp)"
//s1 is 2.718281828
let s2 = String(format: "%0.3f", exp)
//s2 is 2.718
let s3 = String(format: "%0.2E", exp / 100)
//s3 is 2.72E-02
- Log in to post comments