Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating very large whole numbers

I am trying to compute 2^1000 (2 to the power of 1000) using c#. I need the value to all places. I've been scratching my head for a while now because I can't seem to figure out a way to achieve this in c#.

Is there some kind of type that will store a number 300+ digits long, that I'm missing? :)

Thanks

like image 509
Mike Avatar asked Oct 09 '09 14:10

Mike


People also ask

How do computers calculate very large numbers?

Floating point allows computers to store very large numbers and also decimals, but the format still has a specific number of bits, and that limits the range of floating point values and mathematical operations just as with integers.


1 Answers

Yes, but only in .NET 4.0 - System.Numerics.BigInteger.

If you can use .NET 4.0, I'd go for that. Otherwise, I'm sure there are third party libraries around. Let me know if you want me to try to find some.

like image 86
Jon Skeet Avatar answered Sep 20 '22 17:09

Jon Skeet