Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# memory type bigger than ulong

Tags:

c#

math

I need to do huge power calculations (think 2 ^ 1,000,000) in C#, and a ulong is nowhere near sufficient. There's probably not anything bigger implemented in the .NET, but is there some 3rd party thing, or even something I can make that will work?

like image 860
Entity Avatar asked Nov 01 '11 15:11

Entity


2 Answers

If you are using the .NET Framework 4.0, you can use BigInteger. Just add a reference to the System.Numerics assembly.

There are plenty of other implementations as well if the .NET Framework 4.0 isn't available to you, like this one on CodeProject.

like image 53
vcsjones Avatar answered Sep 23 '22 13:09

vcsjones


You can use System.Numerics.BigInteger from .Net 4.0.

like image 35
SLaks Avatar answered Sep 21 '22 13:09

SLaks