I have the following:
package main
import (
"fmt"
"math"
)
func main() {
nums := []float64{
0.15807659924030304, 0.10901273787021637, 0.04955724626779556, 0.05886702239513397,
}
for _, f := range nums {
fmt.Println(f, math.Round(f/.0001)*.0001)
}
}
output is:
0.15807659924030304 0.15810000000000002
0.10901273787021637 0.109
0.04955724626779556 0.049600000000000005
0.05886702239513397 0.0589
Why are some ending up with > 4 decimal places? How do I correct it?