Reputation: 6141
I have a question out of sheer curiosity. How is multiplication of large numbers implemented in MATLAB ? Is it Karatsuba,Toom-3, Fürer or something entirely different ?
Upvotes: 10
Views: 2656
Reputation: 9875
If your numbers are only big, but you don't require a large number of significant digits. You can multiple a small number with each multiplication, such as $10^-1$. Keep track of the number of multiplications $N$ and obtain a value in terms of $10^{-N}$. This can be a temporary work around.
Upvotes: 0
Reputation: 11810
If you are interested in the algorithm for computing for example 139676498390139139676498390676498390*8745566554641239676498390676498390
, then this is what happens:
double
in IEEE® Standard 754doubles
can only accurately represent integers of up to 2^53-1
(check documentation of bitmax
function) (~10^15
, while your numbers are on the order of 10^35
).Have a look at this example code:
>> a=139676498390139139676498390676498390;
>> num2str(a)
ans =
139676498390139141600015724509659136
which is clearly not exactly the value you assigned to a
- only the first 16 digits match.
Upvotes: 5
Reputation: 26069
Adding to the answer, if you need more digits of accuracy, you can try to use this fex file
Upvotes: 3
Reputation: 20915
There is no built-in BigInteger
class, if that is what you mean. You can either use the fixed point toolbox, or import relevant java/.NET classes.
By default, numbers are represented in IEEE double precision floating point format.
Upvotes: 3