Programming-Idioms

History of Idiom 65 > diff from v5 to v6

Edit summary for version 6 :

Version 5

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

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
let s = format!("{:.1}%", 100.0*x);