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
+18.6k Golang : Reset or rewind io.Reader or io.Writer
+2.8k Java : Random alphabets, alpha-numeric or numbers only string generator
+6.2k Nginx : How to block user agent ?
+3.8k Linux : How to set root password in Linux Mint
+30.1k Golang : Math pow(the power of x^y) example
+37.9k Golang : How to iterate over a []string(array)
+18.6k Golang : Set or Add HTTP Request Headers
+5.9k Swift : substringWithRange() function example
+26.1k Golang : Record voice(audio) from microphone to .WAV file
+12.8k Golang : convert(cast) string to float value
+5.8k Golang : How to fix html/template : "somefile" is undefined error?