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
+6.2k Golang : Get environment variable
+6.8k Gogland : Single File versus Go Application Run Configurations
+27k Get file path of temporary file in Go
+10.6k Golang : Generate DSA private, public key and PEM files example
+5.2k Golang : How to search a list of records or data structures
+31.9k Delete a directory in Go
+5.5k Golang : Map within a map example
+4.5k Golang *File points to a file or directory ?
+10.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+6.9k Golang : Generate human readable password
+9.7k Golang : Select region of interest with mouse click and crop from image
+4.1k Javascript : How to get width and height of a div?