Bignum arithmetic

Per Gustafsson per.gustafsson@REDACTED
Mon May 19 16:03:53 CEST 2003


You can't represent
2^1292065245826370511117936813749663282546492063092432089491783276644646
6504617309746646057975239671809
as an erlang bignum as that would require
1292065245826370511117936813749663282546492063092432089491783276644646
6504617309746646057975239671810 bits.

That would be too much for most computers. You probably have to represent
the number as a tuple {2, 1292065245826370511117936813749663282546492063092432089491783276644646
6504617309746646057975239671809} and use some tricky arithmetic.

Per Gustafsson



On Mon, 19 May 2003, Sean Hinde wrote:

> Hi all,
>
> For a bit of light relief I figured it would be fun to make an ssh
> client in Erlang. I figured that with such good bignum support it
> wouldn't be too tricky. So. has anyone any good ideas how to calculate:
>
> 2^1292065245826370511117936813749663282546492063092432089491783276644646
> 6504617309746646057975239671809
>
> without a badarith error?
>
> Tried so far:
>
> math:pow(2, Big_num).   % Ha Ha!
>
> 1 bsl Bignum.  % I had hopes for this one..
>
> Thanks,
>
> Sean
>
>




More information about the erlang-questions mailing list