Reputation: 1896
I have a very large number, assume some transaction id or big money involved. So, how I will handle the calculation on these ( add, multiple etc). Does any other was to store it in the generic storage type( long, long long etc) to take care of such situation? Does boost support the solution?
Upvotes: 3
Views: 8941
Reputation: 1
For This Question We Should Create a
Divided And Conquer Recursive Function And I Show You
How You can Do That :
Problem = Multiple U*V Tow 100 Digit numbers ..
Function Output = (Prod) Return U*V
Long Long Long Integer Numbers ...
Like 9999999999999999*99999999999999999
Create Class Like That in your Programming Language ..
In This Project t(n) = 4t(n/2) + CN !!
Sample For Tow Little Number In Mathematica :
4795 * 2412 = ?
n =4 (Digits of 4795)
Result :
(47 * 10^2 +95) * (24 * 10^2 + 12) =>
=> (47 * 24 * 10^4) + (47 * 12 * 10^2)+ (95 * 24 * 10^2) + 95 *12
=> 47 *24 * 10^4 + 47*12 + 95 * 24 + 10^2 + 95 * 12 = Result Of Function
Best Regards Aj.Duende (Persian Guy)
Upvotes: -1
Reputation: 1399
If your numbers are larger than int, long or double. Use type long long and do not worry about adding, multiplication etc.
Upvotes: -1
Reputation: 1
you can Wrote a large number of classes handle the calculation. use the Array of characters store your data.
Upvotes: 0
Reputation: 84
Please check boost multiprecision library .. It will be handy if your project is already using boost. boost multiprecision library
Upvotes: 5
Reputation: 7799
The closest to a standard is The GNU Multiple Precision Arithmetic Library.
Upvotes: 2
Reputation: 409186
You use a library that handles big numbers, like The GNU Multiple Precision Arithmetic Library which seems to be the most common. Or if you want Boost specifically, there's always the Multiprecision library (which can use GMP as backend).
Upvotes: 8