Logo

Programming-Idioms

History of Idiom 65 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-08-20, 12:02:53

Version 9

2015-08-20, 15:47:54

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

Imports
import std.string : format;
Code
string percent = format("%.1f%%", x * 100.0);