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
+13.5k Golang : unknown escape sequence error
+5.5k Fix yum-complete-transaction error
+14.3k Golang : Rename directory
+12.3k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+28.9k Golang : Saving(serializing) and reading file with GOB
+21.8k Golang : Match strings by wildcard patterns with filepath.Match() function
+18.2k Golang : Get download file size
+5.2k Golang : Reclaim memory occupied by make() example
+4.4k JavaScript : Rounding number to decimal formats to display currency
+7.9k Golang : Routes multiplexer routing example with regular expression control
+11.1k Golang : How to flush a channel before the end of program?
+28.9k Golang : missing Git command