Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​Numerics.​BigInteger

Assembly: System.Runtime.Numerics

Represents an arbitrarily large signed integer.

Properties

public bool
IsEven
Indicates whether the value of the current <see cref="T:System.Numerics.BigInteger" /> object is an even number.
public bool
IsOne
Indicates whether the value of the current <see cref="T:System.Numerics.BigInteger" /> object is <see cref="P:System.Numerics.BigInteger.One" /> .
public bool
IsPowerOfTwo
Indicates whether the value of the current <see cref="T:System.Numerics.BigInteger" /> object is a power of two.
public bool
IsZero
Indicates whether the value of the current <see cref="T:System.Numerics.BigInteger" /> object is <see cref="P:System.Numerics.BigInteger.Zero" /> .
public int
Sign
Gets a number that indicates the sign (negative, positive, or zero) of the current <see cref="T:System.Numerics.BigInteger" /> object.

Methods

public int
CompareTo​(long other)
other The signed 64-bit integer to compare.
Returns A signed integer value that indicates the relationship of this instance to <paramref name="other" /> , as shown in the following table. <list type="table"> <listheader> <term> Return value</term> <description> Description</description> </listheader> <item> <term> Less than zero</term> <description> The current instance is less than <paramref name="other" />.</description> </item> <item> <term> Zero</term> <description> The current instance equals <paramref name="other" />.</description> </item> <item> <term> Greater than zero</term> <description> The current instance is greater than <paramref name="other" />.</description> </item> </list>
Compares this instance to a signed 64-bit integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the signed 64-bit integer.
public int
CompareTo​(BigInteger other)
other The object to compare.
Returns A signed integer value that indicates the relationship of this instance to <paramref name="other" /> , as shown in the following table. <list type="table"> <listheader> <term> Return value</term> <description> Description</description> </listheader> <item> <term> Less than zero</term> <description> The current instance is less than <paramref name="other" />.</description> </item> <item> <term> Zero</term> <description> The current instance equals <paramref name="other" />.</description> </item> <item> <term> Greater than zero</term> <description> The current instance is greater than <paramref name="other" />.</description> </item> </list>
Compares this instance to a second <see cref="T:System.Numerics.BigInteger" /> and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object.
public int
CompareTo​(object obj)
obj The object to compare.
Returns A signed integer that indicates the relationship of the current instance to the <paramref name="obj" /> parameter, as shown in the following table. <list type="table"> <listheader> <term> Return value</term> <description> Description</description> </listheader> <item> <term> Less than zero</term> <description> The current instance is less than <paramref name="obj" />.</description> </item> <item> <term> Zero</term> <description> The current instance equals <paramref name="obj" />.</description> </item> <item> <term> Greater than zero</term> <description> The current instance is greater than <paramref name="obj" />, or the <paramref name="obj" /> parameter is <see langword="null" />.</description> </item> </list>
Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object.
public int
CompareTo​(ulong other)
other The unsigned 64-bit integer to compare.
Returns A signed integer that indicates the relative value of this instance and <paramref name="other" /> , as shown in the following table. <list type="table"> <listheader> <term>Return value</term> <description>Description</description> </listheader> <item> <term>Less than zero</term> <description>The current instance is less than <paramref name="other" />.</description> </item> <item> <term>Zero</term> <description>The current instance equals <paramref name="other" />.</description> </item> <item> <term>Greater than zero</term> <description>The current instance is greater than <paramref name="other" />.</description> </item> </list>
Compares this instance to an unsigned 64-bit integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the unsigned 64-bit integer.
public bool
Equals​(long other)
other The signed 64-bit integer value to compare.
Returns <see langword="true" /> if the signed 64-bit integer and the current instance have the same value; otherwise, <see langword="false" /> .
Returns a value that indicates whether the current instance and a signed 64-bit integer have the same value.
public bool
Equals​(BigInteger other)
other The object to compare.
Returns <see langword="true" /> if this <see cref="T:System.Numerics.BigInteger" /> object and <paramref name="other" /> have the same value; otherwise, <see langword="false" /> .
Returns a value that indicates whether the current instance and a specified <see cref="T:System.Numerics.BigInteger" /> object have the same value.
public bool
Equals​(object obj)
obj The object to compare.
Returns <see langword="true" /> if the <paramref name="obj" /> argument is a <see cref="T:System.Numerics.BigInteger" /> object, and its value is equal to the value of the current <see cref="T:System.Numerics.BigInteger" /> instance; otherwise, <see langword="false" /> .
Returns a value that indicates whether the current instance and a specified object have the same value.
public bool
Equals​(ulong other)
other The unsigned 64-bit integer to compare.
Returns <see langword="true" /> if the current instance and the unsigned 64-bit integer have the same value; otherwise, <see langword="false" /> .
Returns a value that indicates whether the current instance and an unsigned 64-bit integer have the same value.
public long
GetBitLength​()
Returns The minimum non-negative number of bits in two's complement notation without the sign bit.
Gets the number of bits required for shortest two's complement representation of the current instance without the sign bit.
public int
GetByteCount​(bool isUnsigned = False)
isUnsigned <see langword="true" /> to use unsigned encoding; otherwise, <see langword="false" /> .
Returns The number of bytes.
Gets the number of bytes that will be output by <see cref="M:System.Numerics.BigInteger.ToByteArray(System.Boolean,System.Boolean)" /> and <see cref="M:System.Numerics.BigInteger.TryWriteBytes(System.Span{System.Byte},System.Int32@,System.Boolean,System.Boolean)" /> .
public int
GetHashCode​()
Returns A 32-bit signed integer hash code.
Returns the hash code for the current <see cref="T:System.Numerics.BigInteger" /> object.
public byte[]
ToByteArray​()
Returns The value of the current <see cref="T:System.Numerics.BigInteger" /> object converted to an array of bytes.
Converts a <see cref="T:System.Numerics.BigInteger" /> value to a byte array.
public byte[]
ToByteArray​(bool isUnsigned = False, bool isBigEndian = False)
isUnsigned <see langword="true" /> to use unsigned encoding; otherwise, <see langword="false" /> .
isBigEndian <see langword="true" /> to write the bytes in a big-endian byte order; otherwise, <see langword="false" /> .
Returns The value of the current <see cref="T:System.Numerics.BigInteger" /> object converted to an array of bytes.
Returns the value of this <see cref="T:System.Numerics.BigInteger" /> as a byte array using the fewest number of bytes possible. If the value is zero, returns an array of one byte whose element is 0x00.
public string
ToString​()
Returns The string representation of the current <see cref="T:System.Numerics.BigInteger" /> value.
Converts the numeric value of the current <see cref="T:System.Numerics.BigInteger" /> object to its equivalent string representation.
public string
ToString​(IFormatProvider provider)
provider An object that supplies culture-specific formatting information.
Returns The string representation of the current <see cref="T:System.Numerics.BigInteger" /> value in the format specified by the <paramref name="provider" /> parameter.
Converts the numeric value of the current <see cref="T:System.Numerics.BigInteger" /> object to its equivalent string representation by using the specified culture-specific formatting information.
public string
ToString​(string format)
format A standard or custom numeric format string.
Returns The string representation of the current <see cref="T:System.Numerics.BigInteger" /> value in the format specified by the <paramref name="format" /> parameter.
Converts the numeric value of the current <see cref="T:System.Numerics.BigInteger" /> object to its equivalent string representation by using the specified format.
public string
ToString​(string format, IFormatProvider provider)
format A standard or custom numeric format string.
provider An object that supplies culture-specific formatting information.
Returns The string representation of the current <see cref="T:System.Numerics.BigInteger" /> value as specified by the <paramref name="format" /> and <paramref name="provider" /> parameters.
Converts the numeric value of the current <see cref="T:System.Numerics.BigInteger" /> object to its equivalent string representation by using the specified format and culture-specific format information.
public bool
TryFormat​(Span`1 destination, Int32& charsWritten, ReadOnlySpan`1 format = null, IFormatProvider provider = null)
public bool
TryWriteBytes​(Span`1 destination, Int32& bytesWritten, bool isUnsigned = False, bool isBigEndian = False)
protected void
Finalize​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object