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
+13.2k Golang : Get constant name from value
+14.2k How to automatically restart your crashed Golang server
+23.7k Golang : Upload to S3 with official aws-sdk-go package
+7.6k Golang : Getting Echo framework StartAutoTLS to work
+14k Golang : How to convert a number to words
+6.5k Golang : Humanize and Titleize functions
+8k Golang : Oanda bot with Telegram and RSI example
+9.9k Golang : Compare files modify date example
+9.4k Golang : Find correlation coefficient example
+15.1k Golang : ROT47 (Caesar cipher by 47 characters) example
+8.9k Android Studio : Indicate progression with ProgressBar example
+86.2k Golang : How to convert character to ASCII and back