Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add percent sign in string format? [duplicate]

I want to get string like "99.99%" from Double,and I used format to get this:

let rate = 99.99999 let str = String(format: "%.2f%", rate) // output 99.99 

And \% is not allowed. So how to add percent sign in string format, please help me!

like image 705
Lumialxk Avatar asked May 25 '16 06:05

Lumialxk


1 Answers

write % twice:

rate = 99.99 let str = String(format: "%.2f%%", rate) 
like image 75
Bhadresh Kathiriya Avatar answered Sep 26 '22 10:09

Bhadresh Kathiriya