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
+2.8k Java : Random alphabets, alpha-numeric or numbers only string generator
+6k Golang : Get environment variable
+11.3k Golang : How to display image file or expose CSS, JS files from localhost?
+10.5k Golang : Verify Linux user password again before executing a program example
+13.7k Golang : Get all local users and print out their home directory, description and group id
+3.8k JavaScript : Rounding number to decimal formats to display currency
+8.6k Golang : Eroding and dilating image with OpenCV example
+3.7k Chrome : How to block socketloop.com links in Google SERP?
+5.6k Unix/Linux : How to get own IP address ?
+9.3k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+19.6k Golang : Create and resolve(read) symbolic links
+18.3k Golang : Check if os.Stdin input data is piped or from terminal