One of the simplest new additions to the .NET 4.0 framework is an integer with arbitrary length, System.Numerics.BigInteger. Here’s a simple usage example, comparing it to a double:
BigInteger b = BigInteger.Pow(2, 64);
Console.WriteLine("BigInteger: {0}", b.ToString("N"));
Console.WriteLine("Double: {0}", Math.Pow(2, 64).ToString("N"));
Console.WriteLine();
b = BigInteger.Pow(2, 128);
Console.WriteLine("BigInteger: {0}", b.ToString("N"));
Console.WriteLine("Double: {0}", ((double)b).ToString("N"));
The output is:
Not bad.