Programming doubt: Mathematical Operations on Very Large Numbers
Hi All,
A programming doubt:-
We need to multiply (or add) very large numbers. By very large i mean that there might be an overflow problem i.e.
If c = a*b then c will not fit into 32 bit or 64 bit memory storage meant for integers or long long integers.
How do we go about this?
I know few methods (for Product):-
1. Long Hand Multiplication (School method)
2. Karatsuba algorithm
3. Fast Fourier Transform and Inverse Transform method.
I tried 1st method and it worked out pretty well (speed efficiency not at all good for very large numbers!!).
Karatsuba does well for "astronomically big" numbers.
Never tried Fourier method. Any ideas on this??
Apart from these can we do something using "Bitwise operations"??
Can't we store product in separate 32 bits (or 64 bits) (separate bytes) and also keep track of each bit??
I would like to participate in discussions (with my stupid doubts) if someone gives a right kick to this topic.
Thanks in advance 😀
A programming doubt:-
We need to multiply (or add) very large numbers. By very large i mean that there might be an overflow problem i.e.
If c = a*b then c will not fit into 32 bit or 64 bit memory storage meant for integers or long long integers.
How do we go about this?
I know few methods (for Product):-
1. Long Hand Multiplication (School method)
2. Karatsuba algorithm
3. Fast Fourier Transform and Inverse Transform method.
I tried 1st method and it worked out pretty well (speed efficiency not at all good for very large numbers!!).
Karatsuba does well for "astronomically big" numbers.
Never tried Fourier method. Any ideas on this??
Apart from these can we do something using "Bitwise operations"??
Can't we store product in separate 32 bits (or 64 bits) (separate bytes) and also keep track of each bit??
I would like to participate in discussions (with my stupid doubts) if someone gives a right kick to this topic.
Thanks in advance 😀
0