Logo

Programming-Idioms

History of Idiom 65 > diff from v12 to v13

Edit summary for version 13 by :

Version 12

2015-08-23, 10:27:53

Version 13

2015-09-03, 16:23:00

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%"

Code
s = "%.1f%" % 100.0 * x
Doc URL
http://ruby-doc.org/core-2.2.3/String.html#method-i-25