PeterO.BigInteger
PeterO.BigInteger
public sealed class BigInteger : System.IEquatable, System.IComparable
Deprecated. Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.
This class is largely obsolete. It will be replaced by a new version of this class in a different namespace/package and library, called PeterO.Numbers.EInteger
in the PeterO.Numbers
library (in .NET), or com.upokecenter.numbers.EInteger
in the com.github.peteroupc/numbers
artifact (in Java). This new class can be used in the CBORObject.FromObject(object)
method (by including the new library in your code, among other things).
An arbitrary-precision integer. Thread safety: Instances of this class are immutable, so they are inherently safe for use by multiple threads. Multiple instances of this object with the same value are interchangeable, but they should be compared using the "Equals" method rather than the "==" operator.
This class is largely obsolete. It will be replaced by a new version of this class in a different namespace/package and library, called PeterO.Numbers.EInteger
in the PeterO.Numbers
library (in .NET), or com.upokecenter.numbers.EInteger
in the com.github.peteroupc/numbers
artifact (in Java). This new class can be used in the CBORObject.FromObject(object)
method (by including the new library in your code, among other things).
An arbitrary-precision integer. Thread safety: Instances of this class are immutable, so they are inherently safe for use by multiple threads. Multiple instances of this object with the same value are interchangeable, but they should be compared using the "Equals" method rather than the "==" operator.
This class is largely obsolete. It will be replaced by a new version of this class in a different namespace/package and library, called PeterO.Numbers.EInteger
in the PeterO.Numbers
library (in .NET), or com.upokecenter.numbers.EInteger
in the com.github.peteroupc/numbers
artifact (in Java). This new class can be used in the CBORObject.FromObject(object)
method (by including the new library in your code, among other things).
An arbitrary-precision integer. Thread safety: Instances of this class are immutable, so they are inherently safe for use by multiple threads. Multiple instances of this object with the same value are interchangeable, but they should be compared using the "Equals" method rather than the "==" operator.
This class is largely obsolete. It will be replaced by a new version of this class in a different namespace/package and library, called PeterO.Numbers.EInteger
in the PeterO.Numbers
library (in .NET), or com.upokecenter.numbers.EInteger
in the com.github.peteroupc/numbers
artifact (in Java). This new class can be used in the CBORObject.FromObject(object)
method (by including the new library in your code, among other things).
An arbitrary-precision integer. Thread safety: Instances of this class are immutable, so they are inherently safe for use by multiple threads. Multiple instances of this object with the same value are interchangeable, but they should be compared using the "Equals" method rather than the "==" operator.
Member Summary
bitLength()
- Finds the minimum number of bits needed to represent this object's value, except for its sign.CompareTo(PeterO.BigInteger)
- Compares this value to another.Equals(object)
- Determines whether this object and another object are equal.Equals(PeterO.BigInteger)
- Returns whether this number's value equals another number's value.fromBytes(byte[], bool)
- Initializes an arbitrary-precision integer from an array of bytes.fromRadixString(string, int)
- Converts a string to an arbitrary-precision integer.fromString(string)
- Converts a string to an arbitrary-precision integer.GetHashCode()
- Returns the hash code for this instance.One
- Gets the arbitrary-precision integer for one.public static readonly PeterO.BigInteger ONE;
- BigInteger for the number one.toBytes(bool)
- Returns a byte array of this object's value.toRadixString(int)
- Generates a string representing the value of this object, in the given radix.ToString()
- Converts this object to a text string in base 10.valueOf(long)
- Converts a 64-bit signed integer to a big integer.Zero
- Gets the arbitrary-precision integer for zero.
ONE
public static readonly PeterO.BigInteger ONE;
BigInteger for the number one.
One
public static PeterO.BigInteger One { get; }
Deprecated. Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.
Gets the arbitrary-precision integer for one.
Returns:
The arbitrary-precision integer for one.
Zero
public static PeterO.BigInteger Zero { get; }
Deprecated. Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.
Gets the arbitrary-precision integer for zero.
Returns:
The arbitrary-precision integer for zero.
bitLength
public int bitLength();
Finds the minimum number of bits needed to represent this object's value, except for its sign. If the value is negative, finds the number of bits in a value equal to this object's absolute value minus 1.
Return Value:
The number of bits in this object's value. Returns 0 if this object's value is 0 or negative 1.
CompareTo
public sealed int CompareTo( PeterO.BigInteger other);
Compares this value to another.
Parameters:
- other: The parameter other is an arbitrary-precision integer.
Return Value:
Less than 0 if this value is less than, 0 if equal to, or greater than 0 if greater than the other value.
Equals
public override bool Equals( object obj);
Determines whether this object and another object are equal.
Parameters:
- obj: The parameter obj is an arbitrary object.
Return Value:
true
if this object and another object are equal; otherwise, false
.
Equals
public sealed bool Equals( PeterO.BigInteger other);
Deprecated. Use EInteger from PeterO.Numbers/com.upokecenter.numbers and the output of this class's ToString method.
Returns whether this number's value equals another number's value.
Parameters:
- other: An arbitrary-precision integer.
Return Value:
true
if this number's value equals another number's value; otherwise, false
.
fromBytes
public static PeterO.BigInteger fromBytes( byte[] bytes, bool littleEndian);
Initializes an arbitrary-precision integer from an array of bytes.
Parameters:
bytes: A byte array consisting of the two's-complement form of the arbitrary-precision integer to create. The last byte contains the lowest 8-bits, the next-to-last contains the next lowest 8 bits, and so on. To encode negative numbers, take the absolute value of the number, subtract by 1, encode the number into bytes, XOR each byte, and if the most-significant bit of the first byte isn't set, add an additional byte at the start with the value 255. For little-endian, the byte order is reversed from the byte order just discussed.
littleEndian: If true, the byte order is little-endian, or least-significant-byte first. If false, the byte order is big-endian, or most-significant-byte first.
Return Value:
An arbitrary-precision integer. Returns 0 if the byte array's length is 0.
Exceptions:
- System.ArgumentNullException: The parameter bytes is null.
fromRadixString
public static PeterO.BigInteger fromRadixString( string str, int radix);
Converts a string to an arbitrary-precision integer.
Parameters:
str: A text string. The string must contain only characters allowed by the given radix, except that it may start with a minus sign ("-", U+002D) to indicate a negative number. The string is not allowed to contain white space characters, including spaces.
radix: A base from 2 to 36. Depending on the radix, the string can use the basic digits 0 to 9 (U+0030 to U+0039) and then the basic letters A to Z (U+0041 to U+005A). For example, 0-9 in radix 10, and 0-9, then A-F in radix 16.
Return Value:
An arbitrary-precision integer with the same value as given in the string.
Exceptions:
System.ArgumentNullException: The parameter str is null.
System.ArgumentException: The parameter radix is less than 2 or greater than 36.
System.FormatException: The string is empty or in an invalid format.
fromString
public static PeterO.BigInteger fromString( string str);
Converts a string to an arbitrary-precision integer.
Parameters:
- str: A text string. The string must contain only basic digits 0 to 9 (U+0030 to U+0039), except that it may start with a minus sign ("-", U+002D) to indicate a negative number. The string is not allowed to contain white space characters, including spaces.
Return Value:
An arbitrary-precision integer with the same value as given in the string.
Exceptions:
System.ArgumentNullException: The parameter str is null.
System.FormatException: The parameter str is in an invalid format.
GetHashCode
public override int GetHashCode();
Returns the hash code for this instance. No application or process IDs are used in the hash code calculation.
Return Value:
A 32-bit signed integer.
toBytes
public byte[] toBytes( bool littleEndian);
Returns a byte array of this object's value. The byte array will take the form of the number's two' s-complement representation, using the fewest bytes necessary to represent its value unambiguously. If this value is negative, the bits that appear "before" the most significant bit of the number will be all ones.
Parameters:
- littleEndian: If true, the least significant bits will appear first.
Return Value:
A byte array. If this value is 0, returns a byte array with the single element 0.
toRadixString
public string toRadixString( int radix);
Generates a string representing the value of this object, in the given radix.
Parameters:
- radix: A radix from 2 through 36. For example, to generate a hexadecimal (base-16) string, specify 16. To generate a decimal (base-10) string, specify 10.
Return Value:
A string representing the value of this object. If this value is 0, returns "0". If negative, the string will begin with a hyphen/minus ("-"). Depending on the radix, the string will use the basic digits 0 to 9 (U+0030 to U+0039) and then the basic letters A to Z (U+0041 to U+005A). For example, 0-9 in radix 10, and 0-9, then A-F in radix 16.
Exceptions:
- System.ArgumentException: The parameter "index" is less than 0, "endIndex" is less than 0, or either is greater than the string's length, or "endIndex" is less than "index" ; or radix is less than 2 or greater than 36.
ToString
public override string ToString();
Converts this object to a text string in base 10.
Return Value:
A string representation of this object. If negative, the string will begin with a minus sign ("-", U+002D). The string will use the basic digits 0 to 9 (U+0030 to U+0039).
valueOf
public static PeterO.BigInteger valueOf( long longerValue);
Converts a 64-bit signed integer to a big integer.
Parameters:
- longerValue: The parameter longerValue is a 64-bit signed integer.
Return Value:
An arbitrary-precision integer with the same value as the 64-bit number.