Home >Backend Development >C#.Net Tutorial >BigInteger class in C#

BigInteger class in C#

王林
王林forward
2023-08-25 18:25:021685browse

C# 中的 BigInteger 类

Use BigInteger in C# to handle large numbers. The assembly to add for BigInteger is System. numerical value.

In C#, big integers are located in System.Numerics.BigInteger.

Syntax

Syntax of BigInteger-

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

Let’s see a sample code snippet-

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

You can create a BigInteger like this-

BigInteger num = new BigInteger(double.MaxValue);

The following are some of its constructors-

2 3           4
S.No.

Constructor and description

1

##BigInteger(Byte[ ])A new instance of the BigInteger structure using the values ​​in the byte array.

p>

td>

BigInteger(Decimal)Use Decimal value A new instance of the BigInteger structure.

BigInteger(Double)Use double precision A new instance of a BigInteger structure with a floating-point

value.

BigInteger(Int32)Use 32 bits A new instance of a BigInteger structure for signed integer values.

The above is the detailed content of BigInteger class in C#. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete