Created
May 15, 2015 20:01
-
-
Save epequeno/20ec2baa639aa6d039de to your computer and use it in GitHub Desktop.
adding big ints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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