I want to get the string as "99.99%" from Double , and I used the format to get this:
"99.99%"
Double
let rate = 99.99999 let str = String(format: "%.2f%", rate) // output 99.99
And \% not allowed. So, how to add percent sign in string format, please help me!
\%
write two times%:
rate = 99.99 let str = String(format: "%.2f%%", rate)
The% character is used in the printf statement. How would you place this character as part of the display?
You can do this using %% in the printf statement. For example, you can write printf ("10 %%") to display the output as 10% on the screen.
Hope it helps you :)