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
+4.8k Linux/MacOSX : How to symlink a file?
+12.4k Golang : How to check if a string starts or ends with certain characters or words?
+4.9k HTTP common errors and their meaning explained
+8k Golang Hello World Example
+11.2k Golang : Fix go.exe is not compatible with the version of Windows you're running
+10.7k Golang : ISO8601 Duration Parser example
+5.3k Python : Create Whois client or function example
+20.1k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+8.7k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+9.6k Golang : Extract or copy items from map based on value
+7.8k Golang : Generate human readable password
+10.3k Golang : Use regular expression to get all upper case or lower case characters example