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
+19k Golang : Get ASCII code from a key press(cross-platform) example
+3.7k Javascript : How to loop over and parse JSON data?
+32.4k Golang : Convert date or time stamp from string to time.Time type
+17.3k Golang : Convert date string to variants of time.Time type examples
+7.9k Golang : Channels and buffered channels examples
+14.8k Golang : Get current URL example
+4.4k Golang : Handling image beyond OpenCV video capture boundary
+8k Golang : Simple image viewer with Go-GTK
+4k Unix/Linux : How to test user agents blocked successfully ?
+12.2k Golang : Convert(cast) int to float example
+3.8k Golang : Display advertisement images or strings on random order
+5.8k Setting $GOPATH environment variable for Unix/Linux and Windows