Bignum arithmetic

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Bignum arithmetic

Erik Reitsma (RY/ETM)-2
> 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^129206524582637051111793681374966328254649206309243208949178
> 3276644646
> 6504617309746646057975239671809
>
> without a badarith error?

I do not think that this will work, since the result will have 12920652458263705111179368137496632825464920630924320894917832766446466504617309746646057975239671809 bits. :) :)
I do not think that you have enough memory to store such a large number (understatement...). You may need every atom in the universe to store such a large number :)
 
So, you will not be able to calculate this number, in any way.

Since you will have to take the remainder of the result after division by some number (I presume), you will have to multiply step by step (in a smart way), taking remainders after every step.

*Erik.