Handling very large numbers in .Net
My recent attempts at playing the Google Treasure Hunt found me looking for ways to work with very large numbers. My solution to the first puzzle was consistently giving me the wrong answer. After a while I stopped looking at my solution for mistakes and started looking at the answer closely; it turned out that Excel (which is what I was using to generate my answers) lost precision working with very large numbers. Well, I decided to write a program in C# for this and it turned out that even here, we lost precision (and I guess that should have been expected).
Rather than write my own class which can manipulate large numbers, I decided to see if there is anything already available. Well, there is.
One would think that the .Net framework would offer something that allows manipulation of such numbers, and the plan for offering something is there in the form of a .Net class called System.Numeric.BigInteger. However, as of release of version 3.5 of the framework, this class is Internal and can’t be used. So how do I work with numbers like the one below?
Enter Open Source and a project called IntX. IntX is an integer representation written in C# which allows you to work with integers of very large size (over a million digits). This makes the number above fairly small. Kudos to the developer for making this and then making it public.
Incidentally, this was my ‘correct’ answer for Google Treasure Hunt’s first puzzle :).
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

June 5th, 2008 at 8:21 am
Thanks for this post. I was actually looking for a large-int solution for C# to solve the very same Treasure Hunt puzzle you mention in the post, and this was one of the first links that came up on Google for “c# very large numbers”
PS: After switching out Int64 for IntX, I got the correct puzzle answer! (3195948547461617364691901390400)
joelpt
June 5th, 2008 at 10:09 am
@joel
I am glad this helped someone
October 14th, 2008 at 8:17 am
where can I get IntX. I have a project that I need to +, -, *, and / very large numbers and I would love to use IntX
October 14th, 2008 at 11:47 am
@ron - here you go: http://codeplex.com/IntX/