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
+5.8k Golang : Experimenting with the Rejang script
+5.6k Golang : Denco multiplexer example
+22.6k Golang : Test file read write permission example
+54.7k Golang : Unmarshal JSON from http response
+14.7k Golang : package is not in GOROOT during compilation
+9.8k Golang : Bcrypting password
+5k Golang : Pad file extension automagically
+6.2k Golang : Calculate diameter, circumference, area, sphere surface and volume
+4.6k Nginx and PageSpeed build from source CentOS example
+16.4k Golang : Gzip file example
+7.3k Golang : Rename part of filename
+6.5k Golang : Calculate pivot points for a cross