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.8k Android Studio : Image button and button example
+12.8k Golang : http.Get example
+13.1k Golang : How to get a user home directory path?
+7.3k Golang : alternative to os.Exit() function
+13.6k Android Studio : Password input and reveal password example
+4.8k Golang : A program that contain another program and executes it during run-time
+15.3k nginx: [emerg] unknown directive "ssl"
+6.6k Golang : Embedded or data bundling example
+39.6k Golang : Remove dashes(or any character) from string
+5.2k Golang : Issue HTTP commands to server and port example
+6.9k Golang : Normalize email to prevent multiple signups example
+14.9k Golang : How to check for empty array string or string?