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
+14.6k Golang : Overwrite previous output with count down timer
+17.6k Golang : Clone with pointer and modify value
+12.2k Golang : md5 hash of a string
+21.5k Curl usage examples with Golang
+13.7k Golang : Qt progress dialog example
+17.1k Golang : Covert map/slice/array to JSON or XML format
+17.7k Golang : delete and modify XML file content
+32.5k Golang : Copy directory - including sub-directories and files
+10.6k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+9.2k Golang : Write multiple lines or divide string into multiple lines