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
+9.1k Golang : Wait and sync.WaitGroup example
+5.8k Mac OSX : Find large files by size
+10.8k Golang : Save webcamera frames to video file
+16.7k Golang : Get command line arguments
+12.2k Golang : Get dimension(width and height) of image file
+12.4k Golang : Check if an integer is negative or positive
+5.8k Mac/Linux/Windows : Get CPU information from command line
+18.9k Nginx + FastCGI + Go Setup.
+5.1k Golang : Extract XML attribute data with attr field tag example
+6.1k Golang : Validate credit card example
+7.9k Golang : How to get username from email address
+7.6k Golang : Combine slices but preserve order example