Have this code
import (
"fmt"
"math/big"
)
func main() {
var b1,b2,b3,bigSum big.Float
b1.SetFloat64(25.3)
b2.SetFloat64(76.2)
b1.SetFloat64(53.1)
bigSum.Add(&b1, &b2).Add(&b3, &bigSum)
fmt.Println(bigSum) // {53 0 0 1 false [9317046909104082944] 8}
fmt.Println(&bigSum) // 129.3
}
I have 2 questions
Why I have to pass
bigSum
as reference (by using&
) to get the correct answer, otherwise we'll get back an object?How does
Println
work in Go? I mean how does it know which format it should apply for different types?