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
+11.6k Golang : Pagination with go-paginator configuration example
+7.3k Golang : Trim everything onward after a word
+11.3k Get form post value in Go
+15.6k Golang : Loop each day of the current month example
+9.2k Golang : interface - when and where to use examples
+5k Javascript : How to loop over and parse JSON data?
+30.3k Golang : Interpolating or substituting variables in string examples
+7.5k Golang : Scan files for certain pattern and rename part of the files
+5.4k Golang : Find change in a combination of coins example
+28.8k Golang : How to create new XML file ?
+25.2k Golang : How to read integer value from standard input ?