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
+4.9k Javascript : How to get width and height of a div?
+9.6k Golang : Accessing content anonymously with Tor
+17.3k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+8k Golang : Gomobile init produce "iphoneos" cannot be located error
+13.2k Golang : How to get a user home directory path?
+9.3k Golang : How to check if a string with spaces in between is numeric?
+5.1k Golang : micron to centimeter example
+8.5k Golang : Ackermann function example
+20k Golang : How to get time from unix nano example
+24.7k Golang : How to validate URL the right way
+7.4k Golang : File system scanning