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
+9.4k Golang : Listen and Serve on sub domain example
+16.2k Golang : Get path name to current directory or folder
+6.9k Golang : Random integer with rand.Seed() within a given range
+4.1k Golang : How to verify input is rune?
+9.5k Golang : zlib compress file example
+8.7k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+4.6k Mac/Linux/Windows : Get CPU information from command line
+7.1k Golang : Qt Yes No and Quit message box example
+4.1k Golang : Denco multiplexer example
+3.9k Golang : Experimental emojis or emoticons icons programming language
+4.1k Swift : Get substring with rangeOfString() function example
+5.7k Golang : Ways to recover memory during run time.