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
+10.2k Golang : Qt progress dialog example
+4.8k Mac/Linux/Windows : Get CPU information from command line
+7.6k Golang : Print how to use flag for your application example
+26.6k Golang : Login(Authenticate) with Facebook example
+10.8k Golang : Compress and decompress file with compress/flate example
+9.1k Golang : Fuzzy string search or approximate string matching example
+25.2k Golang : Connect to database (MySQL/MariaDB) server
+17.5k Golang : How to count the number of repeated characters in a string?
+8.4k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+8.3k Golang : How to tokenize source code with text/scanner package?
+11.7k Golang : How to filter a map's elements for faster lookup
+6.2k Golang : Randomize letters from a string example