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
+17.3k Golang : Parse date string and convert to dd-mm-yyyy format
+11.9k Golang : Simple client-server HMAC authentication without SSL example
+18.6k Golang : How to make function callback or pass value from function as parameter?
+11.2k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+4.6k Nginx and PageSpeed build from source CentOS example
+25.9k Golang : Get executable name behind process ID example
+6.1k Unix/Linux : Use netstat to find out IP addresses served by your website server
+9.4k Golang : Populate slice with sequential integers example
+9.1k Golang : Terminate-stay-resident or daemonize your program?
+23.4k Golang : Fix type interface{} has no field or no methods and type assertions example
+7.6k Golang : Regular Expression find string example
+13.1k Golang : Verify token from Google Authenticator App