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
+7.3k Android Studio : Image button and button example
+20.5k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+17.3k Golang : Padding data for encryption and un-padding data for decryption
+12.8k Golang : How to check if your program is running in a terminal
+11.1k Golang : Forwarding a local port to a remote server example
+4.4k Golang : Detect words using using consecutive letters in a given string
+8.4k Golang : Format strings to SEO friendly URL example
+10k Google Maps URL parameters configuration
+8.2k Golang : How to get garbage collection data?
+7.8k Golang : Heap sort example
+11.4k Golang : HTTP response JSON encoded data