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
+8k Golang : GMail API create and send draft with simple upload attachment example
+16k Golang : Get number of CPU cores
+50.9k Golang : How to get struct field and value by name
+7.6k Golang : Ackermann function example
+32.6k Golang : All update packages with go get command
+11.5k Golang : Forwarding a local port to a remote server example
+13.1k Golang : concatenate(combine) strings
+22.9k Golang : Upload to S3 with official aws-sdk-go package
+13.7k Golang : Get URI segments by number and assign as variable example
+5.9k Get Facebook friends working in same company
+6.4k Golang : How to detect if a sentence ends with a punctuation?
+10.2k Golang : Read until certain character to break for loop