C# 中的 BigInteger 类
利用 BigInteger 在 C# 中处理大数字。要实现 BigInteger,需添加的程序集是System.Numerics。
在 C# 中,大整数在 System.Numerics.BigInteger 中。
语法
BigInteger 的语法 −
[SerializableAttribute] public struct BigInteger : IFormattable, IComparable, IComparable<BigInteger>, IEquatable<BigInteger>
我们来看一个示例代码片段 −
BigInteger num = BigInteger.Multiply(Int64.MaxValue, Int64.MaxValue);
你可以这样创建 BigInteger −
BigInteger num = new BigInteger(double.MaxValue);
以下是一些构造函数 −
| 序号 | 构造函数 & 说明 |
|---|---|
| 1 | BigInteger(Byte[ ]) 使用字节数组中的值创建 BigInteger 结构的新实例。 |
| 2 | BigInteger(Decimal) 使用十进制值创建一个 BigInteger 结构的新实例。 |
| 3 | BigInteger(Double) 使用双精度浮点值创建一个 BigInteger 结构的新实例。 value。 |
| 4 | BigInteger(Int32) 使用 32 位签名整数值创建一个 BigInteger 结构的新实例。 |
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP