Possible Duplicate:
Big integers in C#
I want to be able to process arbitrarily large numbers in C#.
I can live with just integers.
Are there established algorithms for this kind of thing?
Or is there a good 3rd-party library?
I might consider changing language if there really is no good way to do it in C#.
Thanks for any help / suggestions.
Description: The max() function returns the greater of two values. The max() function is for C programs only. For C++ programs, use the __max() macro.
Longer integers: long The long data type stores integers like int , but gives a wider range of values at the cost of taking more memory. Long stores at least 32 bits, giving it a range of -2,147,483,648 to 2,147,483,647. Alternatively, use unsigned long for a range of 0 to 4,294,967,295.
This number is the data value that is greater than or equal to all other values in our set of data. If we were to order all of our data in ascending order, then the maximum would be the last number listed. The maximum is a unique number for a given set of data.
You might want to check the Big Num kind of libraries. In C# the most popular ones are: IntX and W3b.Sine, plus, they are both Open Source.
Someone has done a BigInteger class in C# at codeproject C# BigInteger Class. Worth checking out.
And a sample of the general algorithm can be found at : Re: Hi-prec math for visual studio c#? (It's the post at the bottom of the page with the code snippet)
As people have mentioned, there are various 3rd-party implementations of a BigInteger class. Also, C# 4.0 will be getting a native BigInteger class in the CLR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With