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
+5.4k Golang : Break string into a slice of characters example
+9.1k Golang : Wait and sync.WaitGroup example
+12.6k Golang : Gin framework accept query string by post request example
+22.8k Golang : How to validate URL the right way
+11.9k Golang : Handle or parse date string with Z suffix(RFC3339) example
+5k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+9.8k Golang : Natural string sorting example
+8.6k Golang : Turn string or text file into slice example
+20.7k Golang : How to run Golang application such as web server in the background or as daemon?
+4.8k Fix fatal error: evacuation not done in time problem
+8.9k Golang : Compare files modify date example
+15.1k Golang :Trim white spaces from a string