You may add 0.5 to it before calling Float.Int(), and you get what you want.
At least for positive numbers. If the number is negative, you have to add -0.5 so e.g. -0.6 gets "rounded" to -1.0.
This is how you can do that:
delta := 0.5
if bf.Sign() < 0 {
delta = -0.5
}
bf.Add(bf, new(big.Float).SetFloat64(delta))
bint, _ := bf.Int(nil)
You may simplify this addition like this if you want to:
bf.Add(bf, new(big.Float).SetFloat64(0.5*float64(bf.Sign())))
Let's test it for some values:
for _, s := range []string{"-0.8", "-0.3", "0.6", "1.1", "1.8"} {
bf, _ := (&big.Float{}).SetString(s)
delta := 0.5
if bf.Sign() < 0 {
delta = -0.5
}
bf.Add(bf, new(big.Float).SetFloat64(delta))
bint, _ := bf.Int(nil)
fmt.Printf("%5s => %2s\n", s, bint)
}
Output (try it on the Go Playground):
-0.8 => -1
-0.3 => 0
0.6 => 1
1.1 => 1
1.8 => 2