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
+11.5k Golang : reCAPTCHA example
+3.8k JavaScript/JQuery : Redirect page examples
+17.7k Golang : Reset or rewind io.Reader or io.Writer
+8.9k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+8.6k JavaScript/JQuery : Detect or intercept enter key pressed example
+17.6k Mac OSX : Homebrew and Golang
+4.4k Linux : Disable and enable IPv4 forwarding
+3.8k Unix/Linux : secure copying between servers with SCP command examples
+5.8k Golang : Dealing with postal or zip code example
+10.8k Golang : Extract part of string with regular expression
+12.5k Golang : Reset buffer example
+5.7k Golang : Check if one string(rune) is permutation of another string(rune)