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
+16.3k PHP : Convert(cast) int to double/float
+6.5k Golang : ffmpeg with os/exec.Command() returns non-zero status
+19.7k Golang : Get executable name behind process ID example
+5k Golang : Gorrila set route name and get the current route name
+3.9k Golang : Find the longest line of text example
+4.8k Web : How to see your website from different countries?
+2.6k Golang : Calculate a pip value and distance to target profit example
+13.9k Golang : Get command line arguments
+10.5k Golang : Date and Time formatting
+7.7k Javascript : Read/parse JSON data from HTTP response
+27.2k Golang : Call a function after some delay(time.Sleep and Tick)
+7k Android Studio : Simple input textbox and intercept key example