Conversions -3 (Textual to Numeric)

Home   »   Conversions -3 (Textual to Numeric)

import UIKit

// Textual to Numeric ( Double(), Int(), Float() )

var number1:String = "10"
var number2:String = "23.48"
var number3:String = "12.54"


var example1 = Int(number1)

var example2 = Double(number2)

var example3 = Float(number3)

// Controlled conversion

if let conversion = Int(number1) {
    print("Conversion Succesfully !")
}

Leave a Reply

Your email address will not be published. Required fields are marked *