Answers for "golang printf specify number of decimals"

Go
0

float number golang two dots

x := 12.3456
fmt.Println(math.Floor(x*100)/100) // 12.34 (round down)
fmt.Println(math.Round(x*100)/100) // 12.35 (round to nearest)
fmt.Println(math.Ceil(x*100)/100)  // 12.35 (round up)
Posted by: Guest on May-12-2020

Code answers related to "golang printf specify number of decimals"

Browse Popular Code Answers by Language