This language bar is your friend. Select your favorite languages!
Edit summary for version 3 :

Version 2

Version 3

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

					
				
Imports
import "fmt"
Code
s := fmt.Sprintf("%.1f%%", 100.0*x)
Code
s := fmt.Sprintf("%.1f%%", 100.0*x)
Comments bubble
The litteral % must be doubled.
Comments bubble
The litteral % must be doubled.
Demo URL
https://play.golang.org/p/QVtaV89w2E
Demo URL
https://play.golang.org/p/QVtaV89w2E