BigInteger Class in C#


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.

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 19-Jun-2020

362 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements