How do you deal with numbers larger than UInt64 (C#)

Alex picture Alex · Aug 19, 2009 · Viewed 28.4k times · Source

In C#, how can one store and calculate with numbers that significantly exceed UInt64's max value (18,446,744,073,709,551,615)?

Answer

Jon Skeet picture Jon Skeet · Aug 19, 2009

Can you use the .NET 4.0 beta? If so, you can use BigInteger.

Otherwise, if you're sticking within 28 digits, you can use decimal - but be aware that obviously that's going to perform decimal arithmetic, so you may need to round at various places to compensate.