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
+8.7k Golang : On lambda, anonymous, inline functions and function literals
+7.7k Golang : Scan files for certain pattern and rename part of the files
+15.1k Golang : Save(pipe) HTTP response into a file
+19.6k Golang : Set or Add HTTP Request Headers
+7.5k Golang : Detect sample rate, channels or latency with PortAudio
+9.6k Golang : Quadratic example
+5.3k Swift : Convert string array to array example
+12.3k Golang : Search and extract certain XML data example
+10.5k Golang : How to delete element(data) from map ?
+4.8k Unix/Linux : secure copying between servers with SCP command examples
+22.3k Golang : Read directory content with filepath.Walk()
+10.4k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine