BigInteger Class in C#

CsharpServer Side ProgrammingProgramming

Use the BigInteger to handle big numbers in C#. The assembly to add for BigInteger is System. Numerics.

In c# Big integer is found in System.Numerics.BigInteger.

Syntax

The syntax of BigInteger −

[SerializableAttribute]
public struct BigInteger : IFormattable, IComparable, IComparable<BigInteger>, IEquatable<BigInteger>

Let us see an example code snippet −

BigInteger num = BigInteger.Multiply(Int64.MaxValue, Int64.MaxValue);

You can create BigInteger like this −

BigInteger num = new BigInteger(double.MaxValue);

The following are some of its constructors −

S.No.
Constructor & Description
1
BigInteger(Byte[ ])
A new instance of the BigInteger structure using the values in a byte array.
2
BigInteger(Decimal)
A new instance of the BigInteger structure using a Decimal value.
            3
BigInteger(Double)
A new instance of the BigInteger structure using a double-precision floating-point
value.
           4
BigInteger(Int32)
A new instance of the BigInteger structure using a 32-bit signed integer value.
raja
Published on 24-Jul-2018 09:07:26
Advertisements