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.7k Golang : Gaussian blur on image and camera video feed examples
+5.2k Golang : Scan forex opportunities by Bollinger bands
+11.3k Golang : Listen and Serve on sub domain example
+10.8k Golang : md5 hash of a string
+18.4k Golang : Count JSON objects and convert to slice/array
+10.8k Golang : Detect user location with HTML5 geo-location
+6.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+4.9k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+4.5k Golang : fmt.Println prints out empty data from struct
+8.3k Golang : How to get ECDSA curve and parameters data?
+16.2k Golang : How to make a file read only and set it to writable again?
+14.3k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type