Package strconv

Table of Contents

func FormatFloat reference

func FormatFloat(f float64, fmt byte, prec, bitSize int) string
fmt
one of "beEfgG'
prec
precision, -1 is special for smallest number.
bitSize
32 or 64
v := 3.1415926535

fmt.Println(strconv.FormatFloat(v, 'E', -1, 32))
fmt.Println(strconv.FormatFloat(v, 'E', -1, 64))
fmt.Println(strconv.FormatFloat(1./3, 'f', 9, 64))
fmt.Println(strconv.FormatFloat(4./5, 'f', 9, 64))
3.1415927E+00
3.1415926535E+00
0.333333333
0.800000000