「Swift」文字列のString型からDouble型への変換のサンプル
書式
atof(文字列)
Double(文字列)
使用例
import Foundation
// atof()メソッド
let cftB:String = "678.231"
let resB:Double = atof(cftB)
print("atof() 結果2:")
print(resB)
// Double()メソッド
let cftA:String = "654.123"
let resA:Double = Double(cftA)!
print("Double() 結果1")
print(resA)
import Foundation
// atof()メソッド
let cftB:String = "678.231"
let resB:Double = atof(cftB)
print("atof() 結果2:")
print(resB)
// Double()メソッド
let cftA:String = "654.123"
let resA:Double = Double(cftA)!
print("Double() 結果1")
print(resA)
import Foundation // atof()メソッド let cftB:String = "678.231" let resB:Double = atof(cftB) print("atof() 結果2:") print(resB) // Double()メソッド let cftA:String = "654.123" let resA:Double = Double(cftA)! print("Double() 結果1") print(resA)
実行結果
atof() 結果2:
678.231
Double() 結果1
654.123