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.8k Golang : Denco multiplexer example
+22.8k Golang : Call function from another package
+12.5k Golang : Gin framework accept query string by post request example
+31.1k Golang : Regular Expression for alphanumeric and underscore
+11.9k Golang : Get user input until a command or receive a word to stop
+12.2k Golang : Get constant name from value
+5.5k Golang : How to determine if request or crawl is from Google robots
+8.2k Golang : Web(Javascript) to server-side websocket example
+11.5k Golang : Transform comma separated string to slice example
+14.9k Golang : Test floating point numbers not-a-number and infinite example
+6.9k Findstr command the Grep equivalent for Windows
+5.4k Unix/Linux : Use netstat to find out IP addresses served by your website server