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
+17.1k Golang : Read integer from file into array
+7.1k Golang : Join lines with certain suffix symbol example
+10.1k Golang : Turn string or text file into slice example
+20.4k Golang : Compare floating-point numbers
+7.6k Golang : Process json data with Jason package
+9.6k Golang : Timeout example
+18.6k Golang : Example for RSA package functions
+12.5k Golang : Print UTF-8 fonts on image example
+7.8k Golang : get the current working directory of a running program
+8.5k Golang : Count leading or ending zeros(any item of interest) example
+8.5k Golang : Number guessing game with user input verification example
+6.7k Golang : Map within a map example