Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 596
Alex Avatar asked Aug 19 '09 09:08

Alex


1 Answers

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.

like image 114
Jon Skeet Avatar answered Oct 01 '22 11:10

Jon Skeet