Swift : Convert (cast) Float to Int or Int32 value
Problem :
How to convert float variable value to type integer in Swift programming language?
Solution :
Use the Int()
function. For examples :
let x : Float = 8.0
var i : Int = Int(x)
or
let x : Float = 8.0
var i : Int32 = Int32(x)
Reference :
See also : Swift : Convert (cast) Float to String
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+13.3k Golang : Qt progress dialog example
+7.7k Setting $GOPATH environment variable for Unix/Linux and Windows
+5.1k Python : Convert(cast) string to bytes example
+9.6k PHP : Get coordinates latitude/longitude from string
+13k Golang : Convert(cast) int to int64
+21.7k Golang : Use TLS version 1.2 and enforce server security configuration over client
+10.8k Golang : Generate random elements without repetition or duplicate
+8.6k Android Studio : Image button and button example
+11.4k Swift : Convert (cast) Float to String
+13.8k Golang : concatenate(combine) strings
+10.1k Golang : Detect number of faces or vehicles in a photo
+31.4k Golang : How to convert(cast) string to IP address?