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
+12.1k Golang : Decompress zlib file example
+6.9k Get Facebook friends working in same company
+27.4k Golang : Convert CSV data to JSON format and save to file
+21.2k Golang : Get password from console input without echo or masked
+4.9k Python : Find out the variable type and determine the type with simple test
+8.4k Useful methods to access blocked websites
+7.2k Golang : Null and nil value
+22.7k Golang : Strings to lowercase and uppercase example
+15.8k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+10.6k Golang : How to unmarshal JSON inner/nested value and assign to specific struct?
+3.4k Golang : Fix go-cron set time not working issue
+15.9k Golang : Update database with GORM example