This language bar is your friend. Select your favorite languages!
Edit summary for version 24 :
New Lua implementation by user [Nepta]

Version 23

Version 24

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Extra Keywords
percent
Extra Keywords
percent
Code
s = string.format("%.1f%%", x*100)
Doc URL
http://www.lua.org/manual/5.3/manual.html#pdf-string.format
Demo URL
http://codepad.org/Tqybmw6y