This question already has an answer here:
- Golang Round to Nearest 0.05 1 answer
I want to trim latitude and longitude of address upto 5 decimal points. latitude and longitude are of type float64 I have created a function round the value. My function is like this::
func DoubleRoundFive(val float64) float64 {
formattedVal := fmt.Sprintf("%.5f", val)
roundedVal, _ := strconv.ParseFloat(formattedVal, 64)
return roundedVal
}
Output and usage::
DoubleRoundFive(76.70289609999999)
Output::
76.7029
But I just want to trim the value upto 5 decimal points. I want output as 76.70289 . Is it possible in GO?? I want exact 5 decimal values because I am using this for latitude longitude. This is a GO playground Link
</div>