Hi all.

I wanted to do something simple - calculate 2^122.

By default Julia returns 0 because of an overflow, so I decided to try using BigInt.

Intuitive solution - BigInt(2^122). Still returns 0 because I’m casting the BigInt after the calculation happened inside. It’s equivalent to x = 2^122; BigInt(x).

So after fiddling I found a solution.

2^(BigInt(122)) returns the correct answer 5316911983139663491615228241121378304

But I have no idea why it works.

Can someone explain to me?

And I wonder if using BigInts will always be troublesome like this…

Thanks!