I want to extract 1 decimal float number from existing float number.
I have done this in Objective-C: Make a float only show two decimal places
Any idea how to make it happen in Swift?
You can make the same in swift :
var formatter : NSString = NSString(format: "%.01f", myFloat)
Or like you want in one line :
println("Pro Forma:- \n Total Experience(In Years) = "+(NSString(format: "%.01f", myFloat)))
This work too with the old NSLog (but prefer println) :
NSLog("Pro Forma:- \n Total Experience(In Years) = %.01f \n", myFloat)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With