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 Golang : Convert slice to array
+8.4k Golang : Another camera capture GUI application with GTK and OpenCV
+13.5k Golang : Query string with space symbol %20 in between
+9k Golang : Simple histogram example
+9.8k Golang : Translate language with language package example
+7k Golang : Array mapping with Interface
+13.9k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+14.3k Golang : How to filter a map's elements for faster lookup
+22.4k Generate checksum for a file in Go
+8.3k Golang : Generate Datamatrix barcode
+27.3k Golang : dial tcp: too many colons in address
+10.8k Nginx : TLS 1.2 support