Swift : Convert (cast) Float to String
Problem :
You have a float value and you need to convert the float into string type in Swift.
Solution :
Use NSString function to cast the float value into string type. For example :
let floatNum = 123.456789
let str = NSString(format: "%.3f", floatNum)
Reference :
See also : Swift : Convert (cast) String to Float
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
+33.7k Golang : Proper way to set function argument default value
+13.8k Javascript : Prompt confirmation before exit
+17.3k Golang : Clone with pointer and modify value
+32.1k Golang : Copy directory - including sub-directories and files
+38.9k Golang : How to read CSV file
+9.9k Golang : Test a slice of integers for odd and even numbers
+29.6k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+7.9k Android Studio : Rating bar example
+14.9k Golang : How to check if IP address is in range
+13.3k Golang : Qt progress dialog example
+18.1k Golang : Get path name to current directory or folder
+7.4k Javascript : Push notifications to browser with Push.js