Skip to content

Instantly share code, notes, and snippets.

@epequeno
Created May 15, 2015 20:01
Show Gist options
  • Save epequeno/20ec2baa639aa6d039de to your computer and use it in GitHub Desktop.
Save epequeno/20ec2baa639aa6d039de to your computer and use it in GitHub Desktop.
adding big ints
package main
import (
"fmt"
"crypto/rand"
"math/big"
)
func main() {
var n *big.Int
var err error
max := *big.NewInt(12)
n, err = rand.Int(rand.Reader, &max)
offset := *big.NewInt(int64(2))
var x *big.Int
x.Add(n, offset)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%d\n", x)
}
// # command-line-arguments
// ./hello.go:19: cannot use offset (type big.Int) as type *big.Int in argument to x.Add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment