Search code examples
gobigintegerint64

Golang overflows int64


I try to use this code, but gives me an error: constant 100000000000000000000000 overflows int64

How can I fix that ?

// Initialise big numbers with small numbers
count, one := big.NewInt(100000000000000000000000), big.NewInt(1)

Solution

  • for example so:

    count,one := new(big.Int), big.NewInt(1)
    count.SetString("100000000000000000000000",10)
    

    link: http://play.golang.org/p/eEXooVOs9Z