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
+20.3k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+4.7k Swift : Get substring with rangeOfString() function example
+6k Golang : Takes a plural word and makes it singular
+12.6k Golang : Reverse IP address for reverse DNS lookup example
+8k Golang : Generate EAN barcode
+19.6k Golang : Clean up null characters from input data
+9.5k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+18.3k Golang : Measure http.Get() execution time
+14.8k Golang : Generate universally unique identifier(UUID) example
+7.4k Golang : Convert word to its plural form example
+5.7k Golang : Humanize and Titleize functions
+16.6k Golang : Aligning strings to right, left and center with fill example