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
+12.4k Golang : Print UTF-8 fonts on image example
+33.7k Golang : How to check if slice or array is empty?
+9.4k Golang : How to get username from email address
+12.8k Golang : flag provided but not defined error
+10.2k Golang : Print how to use flag for your application example
+6.4k Golang : How to search a list of records or data structures
+13.7k Android Studio : Password input and reveal password example
+13.9k Golang : Gin framework accept query string by post request example
+10.9k Golang : Natural string sorting example
+7.3k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+7.2k Golang : Get Alexa ranking data example