Big Integer Structure
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
[SerializableAttribute]
public readonly struct BigInteger : IComparable,
IFormattable, IConvertible, IEquatable<BigInteger>, IComparable<BigInteger>,
IEquatable<int>, IComparable<int>, IBinaryInteger<BigInteger>,
IParsable<BigInteger>, ISpanFormattable, ISpanParsable<BigInteger>,
IAdditionOperators<BigInteger, BigInteger, BigInteger>, IAdditiveIdentity<BigInteger, BigInteger>,
IBinaryNumber<BigInteger>, IBitwiseOperators<BigInteger, BigInteger, BigInteger>,
IComparisonOperators<BigInteger, BigInteger, bool>, IEqualityOperators<BigInteger, BigInteger, bool>,
IDecrementOperators<BigInteger>, IDivisionOperators<BigInteger, BigInteger, BigInteger>,
IIncrementOperators<BigInteger>, IModulusOperators<BigInteger, BigInteger, BigInteger>,
IMultiplicativeIdentity<BigInteger, BigInteger>, IMultiplyOperators<BigInteger, BigInteger, BigInteger>,
INumber<BigInteger>, INumberBase<BigInteger>, IUtf8SpanFormattable,
IUtf8SpanParsable<BigInteger>, ISubtractionOperators<BigInteger, BigInteger, BigInteger>,
IUnaryNegationOperators<BigInteger, BigInteger>, IUnaryPlusOperators<BigInteger, BigInteger>,
IShiftOperators<BigInteger, int, BigInteger>, ISignedNumber<BigInteger>
- Implements
- IComparable, IComparable<BigInteger>, IComparable<Int32>, IConvertible, IEquatable<BigInteger>, IEquatable<Int32>, IFormattable, IParsable<BigInteger>, ISpanFormattable, ISpanParsable<BigInteger>, IUtf8SpanFormattable, IUtf8SpanParsable<BigInteger>, IAdditionOperators<BigInteger, BigInteger, BigInteger>, IAdditiveIdentity<BigInteger, BigInteger>, IBinaryInteger<BigInteger>, IBinaryNumber<BigInteger>, IBitwiseOperators<BigInteger, BigInteger, BigInteger>, IComparisonOperators<BigInteger, BigInteger, Boolean>, IDecrementOperators<BigInteger>, IDivisionOperators<BigInteger, BigInteger, BigInteger>, IEqualityOperators<BigInteger, BigInteger, Boolean>, IIncrementOperators<BigInteger>, IModulusOperators<BigInteger, BigInteger, BigInteger>, IMultiplicativeIdentity<BigInteger, BigInteger>, IMultiplyOperators<BigInteger, BigInteger, BigInteger>, INumber<BigInteger>, INumberBase<BigInteger>, IShiftOperators<BigInteger, Int32, BigInteger>, ISignedNumber<BigInteger>, ISubtractionOperators<BigInteger, BigInteger, BigInteger>, IUnaryNegationOperators<BigInteger, BigInteger>, IUnaryPlusOperators<BigInteger, BigInteger>
Remarks
Use the BigInteger structure to represent integers that may be too large to fit into the built-in integer types. The BigInteger structure can exactly represent numbers up to about 646 million decimal digits.
Big integers can be constructed in a variety of ways, including from other numerical types and from strings. Implicit (widening) conversions are available for all built-in unsigned integer types. Explicit conversions from signed integer types as well as Single, Double and Decimal are also available.
The BigInteger structure provides methods for all the common operations on integers. Overloaded versions of the major arithmetic operators are provided for languages that support them. For languages that don't support operator overloading, equivalent static methods are supplied.
When performing a binary operation, if one of the operands is a BigInteger, then the other operand is required to also be an integral type. Prior to performing the operation, if the other operand is not a BigInteger, it is converted to BigInteger.
Constructors
Big | Constructs a new BigInteger from a byte array containing a two's complement representation of the number. |
Big | Constructs a new BigInteger for a Decimal value. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger from raw data. |
Big | Constructs a new BigInteger. |
Big | Constructs a new BigInteger from a sign and a byte array. |
Properties
Bit | Gets the number of bits in the number. |
Decimal | Gets the number of decimal digits in the number. |
IsEven | Gets whether the number is even. |
IsOdd | Gets whether the number is odd. |
IsOne | Gets whether the number equals 1. |
IsPower | Gets whether the number is a power of two.. |
IsZero | Gets whether the number is zero. |
Limbs | |
Sign | Gets the sign of this BigInteger: -1, 0, or 1. |
Methods
Abs | Returns the absolute value of a number. |
Add | Returns the sum of two BigInteger numbers. |
Binomial | Enumerates over the binomial coefficients of a specified degree. |
Clamp | Clamps a value to an inclusive minimum and maximum value. |
Compare | Compares two numbers. |
Compare | Compares a number to another number. |
Compare | Compares a number to another number. |
Compare | Compares a number to another number. |
Copy | Copies the sign of a value to the sign of another value. |
Divide | Divides one BigInteger by another and returns the result. |
Div | Computes the quotient and remainder of two values. |
Div | Computes the quotient and remainder of two BigInteger numbers. |
Equals( | Tests whether a number equals another number. |
Equals( | Tests whether a number equals another number. |
Equals( |
Returns whether this instance is equal to a specified object.
(Overrides ValueType.Equals(Object)) |
Extended | Returns the greatest common divisor (GCD) of two BigInteger numbers. |
Factorial | Gets the factorial of a number. |
Factorial2 | Gets the double factorial of a number. |
Get |
Returns the hash code for this instance.
(Overrides ValueType.GetHashCode()) |
Get | Gets the Type of the current instance. (Inherited from Object) |
Greatest | Returns the greatest common divisor (GCD) of two BigInteger numbers. |
IsBit | |
IsNegative | Determines if a value represents a negative real number. |
IsPositive | Determines if a value represents zero or a positive real number. |
IsPseudo | Uses the Rabin-Miller test to determine if a number is pseudo-prime. |
Least | Returns the least common multiple (LCM) of two BigInteger numbers. |
Left | Shifts the bits to the left, padding the right with zeros. |
Log2 | Computes the log2 of a value. |
Max | Returns the largest of two numbers. |
Max | Compares two values to compute which has the greater magnitude. |
Min | Returns the smallest of two numbers. |
Min | Compares two values to compute which has the lesser magnitude. |
Mod | Returns the remainder after dividing one BigInteger by another and returns the result. |
Modular | Computes the modular inverse of an integer with respect to the specified modulus. |
Modular | Raises a number to a power modulo another number. |
Modular | Raises a number to a power modulo another number. |
Modulus | Returns the remainder after dividing one BigInteger by another and returns the result. |
Multiply( | Returns the product of two BigInteger numbers. |
Multiply( | Returns the product of a BigInteger number and an integer. |
Multiply( | Returns the product of a BigInteger number and an unsigned integer. |
Multiply( | Returns the product of an integer and a BigInteger number. |
Multiply( | Returns the product of an unsigned integer and a BigInteger number. |
Negate | Returns a BigInteger with the opposite sign. |
Parse( | Converts the string representation of a number to its BigInteger equivalent. |
Parse( | Parses a span of characters into a value. |
Parse( | Converts the string representation of a number in a specified style to its BigInteger equivalent. |
Parse( | Converts the string representation of a number in a specified culture-specific format to its BigInteger equivalent. |
Parse( | Parses a span of characters into a value. |
Parse( | Converts the string representation of a number in a specified style and culture-specific format to its BigInteger equivalent. |
Pow( | Raises a number to the specified power and returns the result as a BigInteger number. |
Pow( | Raises a number to the specified power and returns the result as a BigInteger number. |
Random | Returns a random BigInteger number with the specified number of bits. |
Right | Shifts the bits to the right, discarding bits on the right. |
Right | Shifts the bits to the right with rounding. |
Sqrt | Computes the integer square root of a number. |
Square | Returns the square of a BigInteger number. |
Subtract | Returns the difference between two BigInteger numbers. |
ToByte | Converts a BigInteger value to a byte array. |
ToString() |
Returns a string representation of the number.
(Overrides ValueType.ToString()) |
ToString( | Formats the value of the current instance using the specified format. |
ToString( | Formats the value of the current instance using the specified format. |
Try | Tries to format the value of the current instance into the provided span of characters. |
Try | Converts the string representation of a number to its BigInteger equivalent. A return value indicates whether the conversion succeeded or failed. |
Try | Tries to parse a span of characters into a value. |
Try | Tries to parse a string into a value. |
Try | Tries to parse a span of characters into a value. |
Try | Converts the string representation of a number in a specified style and culture-specific format to its BigInteger equivalent. A return value indicates whether the conversion succeeded or failed. |
Xor | Computes the bitwise exclusive or of two BigInteger values. |
Operators
Addition( | Returns the sum of two BigInteger numbers. |
Addition( | Returns the sum of a BigInteger and a 32 bit integer. |
Addition( | Returns the sum of a 32 bit integer and a BigInteger. |
Bitwise | Computes the bitwise and of two BigInteger values. |
Bitwise | Computes the bitwise and of two BigInteger values. |
Decrement( | Decrements a value. |
Division( | Divides one BigInteger by another and returns the result. |
Division( | Divides one BigInteger by another and returns the result. |
Equality( | Returns whether a BigInteger is equal to another and returns the result. |
Equality( | Returns whether a BigInteger is equal to an integer. |
Equality( | Returns whether a BigInteger is equal to an integer. |
Exclusive | Computes the bitwise exclusive or of two BigInteger values. |
Explicit(BigInteger to Byte) | Converts a BigInteger to a Byte value. |
Explicit(BigInteger to Decimal) | Converts a BigInteger to a Decimal number. |
Explicit(BigInteger to Double) | Converts a BigInteger to a double-precision floating-point number. |
Explicit(BigInteger to Int16) | Converts a BigInteger to a Int16 value. |
Explicit(BigInteger to Int32) | Converts a BigInteger to a Int32 value. |
Explicit(BigInteger to Int64) | Converts a BigInteger to a long integer. |
Explicit(BigInteger to SByte) | Converts a BigInteger to a SByte value. |
Explicit(BigInteger to Single) | Converts a BigInteger to a single-precision floating-point number. |
Explicit(BigInteger to UInt16) | Converts a BigInteger to a UInt16 value. |
Explicit(BigInteger to UInt32) | Converts a BigInteger to an unsigned integer. |
Explicit(BigInteger to UInt64) | Converts a BigInteger to a long unsigned integer. |
Explicit(Decimal to BigInteger) | Converts a Decimal number to a BigInteger value. |
Explicit(Double to BigInteger) | Converts a double-precision floating-point number to a BigInteger value. |
Explicit(Single to BigInteger) | Converts a single-precision floating-point number to a BigInteger value. |
Exponent( | Represents the exponentiation operator. |
Exponentiation( | Represents the exponentiation operator. |
Greater | Returns whether a BigInteger is greater than another and returns the result. |
Greater | Returns whether an integer is greater than a BigInteger. |
Greater | Returns whether an integer is greater than a BigInteger. |
Greater | Returns whether a BigInteger is greater than or equal to another and returns the result. |
Greater | Returns whether an integer is greater than or equal to a BigInteger. |
Greater | Returns whether an integer is greater than or equal to a BigInteger. |
Implicit(Byte to BigInteger) | Converts a Byte value to a BigInteger number. |
Implicit(Int128 to BigInteger) | Converts a 128 bit signed integer to a BigInteger value. |
Implicit(Int16 to BigInteger) | Converts a 16 bit signed integer to a BigInteger value. |
Implicit(Int32 to BigInteger) | Converts a 32 bit signed integer to a BigInteger value. |
Implicit(Int64 to BigInteger) | Converts a 64 bit signed integer to a BigInteger value. |
Implicit(SByte to BigInteger) | Converts a signed byte to a BigInteger value. |
Implicit(UInt128 to BigInteger) | Converts a 128 bit unsigned integer to a BigInteger value. |
Implicit(UInt16 to BigInteger) | Converts a 16 bit unsigned integer to a BigInteger value. |
Implicit(UInt32 to BigInteger) | Converts a 32 bit unsigned integer to a BigInteger value. |
Implicit(UInt64 to BigInteger) | Converts a 64 bit unsigned integer to a BigInteger value. |
Increment( | Increments a value. |
Inequality( | Returns whether a BigInteger is not equal to another and returns the result. |
Inequality( | Returns whether a BigInteger is not equal to an integer. |
Inequality( | Returns whether a BigInteger is not equal to an integer. |
Left | Shifts the bits to the left, padding the right with zeros. |
Less | Returns whether a BigInteger is less than another and returns the result. |
Less | Returns whether an integer is less than a BigInteger. |
Less | Returns whether an integer is less than a BigInteger. |
Less | Returns whether a BigInteger is less than or equal to another and returns the result. |
Less | Returns whether an integer is less than or equal to a BigInteger. |
Less | Returns whether an integer is less than or equal to a BigInteger. |
Modulus( | Returns the remainder after dividing one BigInteger by another and returns the result. |
Multiply( | Returns the product of two BigInteger numbers. |
Multiply( | Returns the product of a BigInteger number and an integer. |
Multiply( | Returns the product of a BigInteger number and an unsigned integer. |
Multiply( | Returns the product of an integer and a BigInteger number. |
Multiply( | Returns the product of an unsigned integer and a BigInteger number. |
Ones | Returns the one's complement of a BigInteger. |
Right | Shifts the bits to the right, discarding bits on the right. |
Subtraction( | Returns the difference between two BigInteger numbers. |
Subtraction( | |
Unary | Returns a BigInteger with the opposite sign. |
Unary | Returns the value of a BigInteger. |
Fields
Max | The largest possible BigInteger. |
Minus | The number -1 as a BigInteger. |
Min | The smallest possible BigInteger. |
One | The number one as a BigInteger. |
Zero | The number zero as a BigInteger. |