package main
import (
"fmt"
"math"
)
func roundToTwoDecimalPlaces(value float64) float64 {
return math.Round(value*100) / 100
}
func main() {
number := 2.431;
rounded := roundToTwoDecimalPlaces(number)
fmt.Printf("Rounded: %.2f\n", rounded)
number = 2.457;
rounded = roundToTwoDecimalPlaces(number)
fmt.Printf("Rounded: %.2f\n", rounded)
}
/*
run:
Rounded: 2.43
Rounded: 2.46
*/