Hi, I have a set of numbers formatted as such - 6.11104586446241e-01 - thatt I want to convert to doubles. In Objective C I'd accomplish this with something like
[NSDecimal Number decimalNumberWithString:theNumber
However when I look up that command it only is listed in Objective C. Is there a Swift way to do this conversion? I'd rather not have to convert all 10,000 of these guys by hand! 🙂
Thanks.
John
If you want to use NSDecimalNumber, it's available in Swift and its `+ decimalNumberWithString:` is imported into Swift as initializer:
let theNumber = "-6.11104586446241e-01"
let decimalValue = NSDecimalNumber(string: theNumber)
(You cannot have space character after minus sign.)
But if you want to get Swift Doubles, you can use initializer of Double.
let doubleValue = Double(theNumber)