How to convert a decimal to a double in Swift

1 Answer

0 votes
import Foundation

let dec = Decimal(string: "12.3456")!
let d = NSDecimalNumber(decimal: dec).doubleValue

print("Decimal value: \(dec)")
print("Double value: \(d)")



/*
run:

Decimal value: 12.3456
Double value: 12.3456

*/


 



answered Apr 12 by avibootz
...