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
+21.8k Golang : How to reverse slice or array elements order
+10.3k Golang : Convert file unix timestamp to UTC time example
+9.5k Golang : Accessing content anonymously with Tor
+9.7k Golang : Populate slice with sequential integers example
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+18.6k Golang : Get download file size
+5.8k Javascript : How to replace HTML inside <div>?
+7.1k Golang : Squaring elements in array
+10.5k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+8.7k Golang : How to join strings?
+21.1k Golang : Sort and reverse sort a slice of strings