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
+5.2k Golang : Display packages names during compilation
+15.2k Golang : How do I get the local IP (non-loopback) address ?
+5.8k Golang : Shortening import identifier
+9.7k Golang : Accessing content anonymously with Tor
+14.2k Golang : Human readable time elapsed format such as 5 days ago
+37.8k Upload multiple files with Go
+6.4k Golang & Javascript : How to save cropped image to file on server
+12.3k Golang : convert(cast) string to integer value
+26.4k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+7k Golang : Experimental emojis or emoticons icons programming language
+11.1k Golang : Create Temporary File
+17.2k Golang : Get the IPv4 and IPv6 addresses for a specific network interface