Logo

Programming-Idioms

History of Idiom 65 > diff from v26 to v27

Edit summary for version 27 by 1.7.4:
New JS implementation by user [1.7.4]

Version 26

2018-06-24, 11:00:03

Version 27

2019-01-23, 19:18:53

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
const s = Math.round (x * 1000) / 10 + '%'
Comments bubble
Sadly there's no builtin in JavaScript for this sort of thing.