big.Int是golang提供的数据类型,用来处理比较大的整型数,当然它也可以处理诸如64bit,32bit的常用整数。
# /go-1.x/src/math/big/int.go
package big
type Int struct {
neg bool // sign, whether negaive
abs nat // absolute value of integer
}
big.Int是一个结构体(struct),相当于C++中的class,所以每次新建big.Int时可以用 x := new(big.Int), 返回一个指针。注意对Int的算术操作,要使用该对象的成员函数,比如Add():
func (z *Int) Add(x, y *Int) *Int // Add sets z to sum x+y and returns z