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
+20.2k Nginx + FastCGI + Go Setup.
+6.9k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+9.4k Golang : Populate slice with sequential integers example
+16.5k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+12k Golang : Get month name from date example
+12.7k Golang : Get terminal width and height example
+27.7k Golang : Move file to another directory
+7.5k Golang : Generate human readable password
+11.7k Golang : Sort and reverse sort a slice of runes
+5.1k Unix/Linux/MacOSx : How to remove an environment variable ?
+42.6k Golang : Convert []byte to image
+6.6k Golang : Calculate pivot points for a cross