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 Golang : Create Temporary File
+6.5k Golang : Sort lines of text example
+19.1k Golang : Convert Unix timestamp to UTC timestamp
+5.8k Golang : Get all countries phone codes
+3.7k Golang : Return multiple values from function
+10.1k Golang : Exit, terminating or aborting a program
+13k Golang : Read large file with bufio.Scanner cause token too long error
+4k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+3k Javascript : How to show different content with noscript?
+4.4k Golang : Extract unicode string from another unicode string example
+5.6k Golang : How to convert strange string to JSON with json.MarshalIndent
+2.1k Java : Get FX sentiment from website example