jaymeister
jaymeister

Reputation: 53

calculating large number powers in matlab

I am trying to figure out how to compute large powers of huge numbers in matlab to do RSA encryption.

For example: A 50+ digit integer raised to the power of 999999.

Upvotes: 3

Views: 2468

Answers (3)

user13267
user13267

Reputation: 7193

We need to implement some form of large number data type
For C this is done using GMP Multiprecision library or LibToMMath Library
There are many others as well
For Matlab may be this will be helpful >>> LInK <<<

Upvotes: 0

Gunther Struyf
Gunther Struyf

Reputation: 11168

So the end result will be around 1e49^1e6 = 1e49000000. This is too large a number for any basic matlab datatype to hold. A solution is to use the vpi toolbox of the file exchange; it can handle large numbers, at the cost of speed.

A better solution would exist in getting your end objective on a different manner; ie redefine the formulas to get the final result..

Upvotes: 2

Oli
Oli

Reputation: 16055

You can use exponentiation by squaring:

https://en.wikipedia.org/wiki/Exponentiation_by_squaring

Upvotes: 3

Related Questions