I want to convert a Float to an Int in Swift. Basic casting like this does not work because these types are not primitives, unlike float
Float
Int
float
Just use type casting
var floatValue:Float = 5.4 var integerValue:Int = Int(floatValue) println("IntegerValue = \(integerValue)")
it will show roundoff value eg: IntegerValue = 5 means the decimal point will be loss