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(字节[)) 新建一个 BigInteger 结构,使用字节数组中的值。 |
| 2 | BigInteger(十进制) 新建一个 BigInteger 结构,使用十进制值。 |
| 3 | BigInteger(双精度) 新建一个 BigInteger 结构,使用双精度浮点数 值。 |
| 4 | BigInteger(Int32) 新建一个 BigInteger 结构,使用 32 位有符号整数值。 |
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP