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
+11k Golang : Get current time
+6.1k Golang : On lambda, anonymous, inline functions and function literals
+32.8k Golang : Use wildcard patterns with filepath.Glob() example
+5.3k Findstr command the Grep equivalent for Windows
+6k Golang : How to use Gorilla webtoolkit context package properly
+8.7k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+8.1k Golang : How to login and logout with JWT example
+22k Golang : Calculate future date with time.Add() function
+15.1k Golang : How to get struct tag and use field name to retrieve data?
+12.1k Golang : Parse date string and convert to dd-mm-yyyy format
+6.7k Golang : Get UDP client IP address and differentiate clients by port number