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
+7.9k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+9.4k Golang : Underscore string example
+6.2k Golang : How to handle file size larger than available memory panic issue
+13.1k Golang : Recombine chunked files example
+9k Android Studio : Simple input textbox and intercept key example
+5k Golang : Detect variable or constant type
+40.2k Golang : Convert string to array/slice
+12.1k Golang : Image to ASCII art example
+3.3k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+6.1k Golang : Accessing dataframe-go element by row, column and name example
+13.4k Golang : Save(pipe) HTTP response into a file
+15.7k Golang : Find file size(disk usage) with filepath.Walk