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
+8.1k Golang : Convert file content to Hex
+4.5k Golang : Extract unicode string from another unicode string example
+11.9k Golang : syscall.Socket example
+16.1k Golang : Read binary file into memory
+34.6k Golang : Convert(cast) int64 to string
+20.1k Generate checksum for a file in Go
+13.7k Golang : How to remove certain lines from a file
+49.9k Golang : Unmarshal JSON from http response
+15.6k Convert JSON to CSV in Golang
+9.3k Google Maps URL parameters configuration
+8.8k Golang : Command line file upload program to server example
+26.9k Golang : bufio.NewReader.ReadLine to read file line by line