Home Removing decimal dot
Reply: 1

Removing decimal dot

Jorge
1#
Jorge Published in 2017-11-14 22:20:08Z

I'm currently developing a iOS (SWIFT) app where I need to remove the dot in decimal values.

For example:

20.50 -> 2050

20.00 -> 2000

Then add 2 zero at the end of the string.

In android i can do this:

java.text.DecimalFormat("#.00").format(amount))

but there is no such thing like DecimalFormat in Swift or am I wrong?

Nic Laughter
2#
Nic Laughter Reply to 2017-11-14 23:30:10Z

let num = 123.45 let str = String(format: "%.00f", num * 100) print(str)

prints 12345

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.344948 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO