Keep number longer than 64 bit

I need to keep the program number longer than long or Int64. Because if I use long, it will return only 0.

+4
source share
3 answers

You can use BigInteger in .Net 4.0

The BigInteger type is an immutable type, which is an arbitrarily large integer whose value in theory does not have an upper or lower bound. Members of the BigInteger type are closely related to the types of other integral types (bytes, Int16, Int32, Int64, SByte, UInt16, UInt32, and UInt64). This type is different from the other type integral in the .NET Framework, which have the range indicated by their MinValue and MaxValue Properties.

If you don’t have the luxury of switching to .Net 4. then you can use an open source project to help you name IntX .

IntX is a library of arbitrary integers written in pure C # 2.0 with a quick implementation of O (N * log N) - multiplication / division algorithms. It provides all basic arithmetic operations on integers, comparison, bitwise offset, etc. It also allows you to analyze numbers in different databases and convert them to a string, also in any database. The advantage of this library is fast multiplication, division and basic / basic conversion algorithms. All fast versions of the algorithms are based on the fast multiplication of large integers using Fast Hartley Transform, which works for O (N * log N * log log N) instead of the classic O (N ^ 2).

+9
source

Try BigInteger

The BigInteger type is an immutable type, which is an arbitrarily large integer whose value in theory does not have an upper or lower bound.

+9
source

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

There are many other implementations if the .NET Framework 4.0 not available to you, for example this one in CodeProject.

+5
source

All Articles