PeterO.Numbers.EInteger

## PeterO.Numbers.EInteger

public sealed class EInteger :
    System.IComparable,
    System.IEquatable

Represents an arbitrary-precision integer. (The “E” stands for “extended”, and has this prefix to group it with the other classes common to this library, particularly EDecimal, EFloat, and ERational.) 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.

Security note

It is not recommended to implement security-sensitive algorithms using the methods in this class, for several reasons:

Applications should instead use dedicated security libraries to handle big numbers in security-sensitive algorithms.

Member Summary

### IsEven

public bool IsEven { get; }

Gets a value indicating whether this value is even.

Returns:

true if this value is even; otherwise, false .

### IsPowerOfTwo

public bool IsPowerOfTwo { get; }

Gets a value indicating whether this object’s value is a power of two, and greater than 0.

Returns:

true if this object’s value is a power of two, and greater than 0; otherwise, false .

### IsZero

public bool IsZero { get; }

Gets a value indicating whether this value is 0.

Returns:

true if this value is 0; otherwise, false .

### One

public static PeterO.Numbers.EInteger One { get; }

Gets the number 1 as an arbitrary-precision integer.

Returns:

The number 1 as an arbitrary-precision integer.

### Sign

public int Sign { get; }

Gets the sign of this object’s value.

Returns:

The sign of this object’s value.

### Ten

public static PeterO.Numbers.EInteger Ten { get; }

Gets the number 10 as an arbitrary-precision integer.

Returns:

The number 10 as an arbitrary-precision integer.

### Zero

public static PeterO.Numbers.EInteger Zero { get; }

Gets the number zero as an arbitrary-precision integer.

Returns:

The number zero as an arbitrary-precision integer.

### Abs

public PeterO.Numbers.EInteger Abs();

Returns the absolute value of this object’s value.

Return Value:

This object’s value with the sign removed.

### Add

public PeterO.Numbers.EInteger Add(
    int intValue);

Adds this arbitrary-precision integer and a 32-bit signed integer and returns the result.

Parameters:

Return Value:

The sum of the two numbers, that is, this arbitrary-precision integer plus a 32-bit signed integer.

### Add

public PeterO.Numbers.EInteger Add(
    long longValue);

Adds this arbitrary-precision integer and a 64-bit signed integer and returns the result.

Parameters:

Return Value:

The sum of the two numbers, that is, this arbitrary-precision integer plus a 64-bit signed integer.

### Add

public PeterO.Numbers.EInteger Add(
    PeterO.Numbers.EInteger bigintAugend);

Adds this arbitrary-precision integer and another arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The sum of the two numbers, that is, this arbitrary-precision integer plus another arbitrary-precision integer.

Exceptions:

### And

public PeterO.Numbers.EInteger And(
    PeterO.Numbers.EInteger other);

Does an AND operation between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bits of this integer and the other integer (in their two’s-complement representation) are both set. For example, in binary, 10110 AND 01100 = 00100 (or in decimal, 22 AND 12 = 4). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11100111 AND 01100 = 00100 (or in decimal, -25 AND 12 = 4).

Exceptions:

### And

public static PeterO.Numbers.EInteger And(
    PeterO.Numbers.EInteger a,
    PeterO.Numbers.EInteger b);

Does an AND operation between two arbitrary-precision integer values.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bits of the two integers are both set.

Exceptions:

### AndNot

public PeterO.Numbers.EInteger AndNot(
    PeterO.Numbers.EInteger second);

Does an AND NOT operation between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set, and the other integer’s corresponding bit is not set. For example, in binary, 10110 AND NOT 11010 = 00100 (or in decimal, 22 AND NOT 26 = 4). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101110 AND NOT 01011 = 00100 (or in decimal, -18 OR 11 = 4).

Exceptions:

### AsInt32Checked

public int AsInt32Checked();

Deprecated. Renamed to ToInt32Checked.

Converts this object’s value to a 32-bit signed integer, throwing an exception if it can’t fit.

Return Value:

A 32-bit signed integer.

Exceptions:

### AsInt32Unchecked

public int AsInt32Unchecked();

Deprecated. Renamed to ToInt32Unchecked.

Converts this object’s value to a 32-bit signed integer. If the value can’t fit in a 32-bit integer, returns the lower 32 bits of this object’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ) (in which case the return value might have a different sign than this object’s value).

Return Value:

A 32-bit signed integer.

### AsInt64Checked

public long AsInt64Checked();

Deprecated. Renamed to ToInt64Checked.

Converts this object’s value to a 64-bit signed integer, throwing an exception if it can’t fit.

Return Value:

A 64-bit signed integer.

Exceptions:

### AsInt64Unchecked

public long AsInt64Unchecked();

Deprecated. Renamed to ToInt64Unchecked.

Converts this object’s value to a 64-bit signed integer. If the value can’t fit in a 64-bit integer, returns the lower 64 bits of this object’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ) (in which case the return value might have a different sign than this object’s value).

Return Value:

A 64-bit signed integer.

### CanFitInInt32

public bool CanFitInInt32();

Returns whether this object’s value can fit in a 32-bit signed integer.

Return Value:

true if this object’s value is from -2147483648 through 2147483647; otherwise, false .

### CanFitInInt64

public bool CanFitInInt64();

Returns whether this object’s value can fit in a 64-bit signed integer.

Return Value:

true if this object’s value is from -9223372036854775808 through 9223372036854775807; otherwise, false .

### CompareTo

public int CompareTo(
    int intValue);

Compares an arbitrary-precision integer with this instance.

Parameters:

Return Value:

Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater.

### CompareTo

public int CompareTo(
    long longValue);

Compares an arbitrary-precision integer with this instance.

Parameters:

Return Value:

Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater.

### CompareTo

public sealed int CompareTo(
    PeterO.Numbers.EInteger other);

Compares an arbitrary-precision integer with this instance.

Parameters:

Return Value:

Zero if the values are equal; a negative number if this instance is less, or a positive number if this instance is greater. This implementation returns a positive number if other is null, to conform to the.NET definition of CompareTo. This is the case even in the Java version of this library, for consistency’s sake, even though implementations of Comparable.CompareTo() in Java ought to throw an exception if they receive a null argument rather than treating null as less or greater than any object.

.

### Decrement

public PeterO.Numbers.EInteger Decrement();

Returns one subtracted from this arbitrary-precision integer.

Return Value:

The given arbitrary-precision integer minus one.

### Divide

public PeterO.Numbers.EInteger Divide(
    int intValue);

Divides this arbitrary-precision integer by a 32-bit signed integer and returns the result. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other 32-bit signed integer is negative, or vice versa, and will be positive if both are positive or both are negative.

Parameters:

Return Value:

The result of dividing this arbitrary-precision integer by a 32-bit signed integer. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other 32-bit signed integer is negative, or vice versa, and will be positive if both are positive or both are negative.

Exceptions:

### Divide

public PeterO.Numbers.EInteger Divide(
    long longValue);

Divides this arbitrary-precision integer by a 64-bit signed integer and returns the result. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other 64-bit signed integer is negative, or vice versa, and will be positive if both are positive or both are negative.

Parameters:

Return Value:

The result of dividing this arbitrary-precision integer by a 64-bit signed integer. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other 64-bit signed integer is negative, or vice versa, and will be positive if both are positive or both are negative.

### Divide

public PeterO.Numbers.EInteger Divide(
    PeterO.Numbers.EInteger bigintDivisor);

Divides this arbitrary-precision integer by another arbitrary-precision integer and returns the result. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other arbitrary-precision integer is negative, or vice versa, and will be positive if both are positive or both are negative.

Parameters:

Return Value:

The result of dividing this arbitrary-precision integer by another arbitrary-precision integer. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other arbitrary-precision integer is negative, or vice versa, and will be positive if both are positive or both are negative.

Exceptions:

### DivRem

public PeterO.Numbers.EInteger[] DivRem(
    int intDivisor);

Divides this arbitrary-precision integer by a 32-bit signed integer and returns a two-item array containing the result of the division and the remainder, in that order. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other 32-bit signed integer is negative, or vice versa, and will be positive if both are positive or both are negative. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other 32-bit signed integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

An array of two items: the first is the result of the division as an arbitrary-precision integer, and the second is the remainder as an arbitrary-precision integer. The result of division is the result of the Divide method on the two operands, and the remainder is the result of the Remainder method on the two operands.

Exceptions:

### DivRem

public PeterO.Numbers.EInteger[] DivRem(
    long intDivisor);

Divides this arbitrary-precision integer by a 64-bit signed integer and returns a two-item array containing the result of the division and the remainder, in that order. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other 64-bit signed integer is negative, or vice versa, and will be positive if both are positive or both are negative. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other 64-bit signed integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

An array of two items: the first is the result of the division as an arbitrary-precision integer, and the second is the remainder as an arbitrary-precision integer. The result of division is the result of the Divide method on the two operands, and the remainder is the result of the Remainder method on the two operands.

### DivRem

public PeterO.Numbers.EInteger[] DivRem(
    PeterO.Numbers.EInteger divisor);

Divides this arbitrary-precision integer by another arbitrary-precision integer and returns a two-item array containing the result of the division and the remainder, in that order. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other arbitrary-precision integer is negative, or vice versa, and will be positive if both are positive or both are negative. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other arbitrary-precision integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

An array of two items: the first is the result of the division as an arbitrary-precision integer, and the second is the remainder as an arbitrary-precision integer. The result of division is the result of the Divide method on the two operands, and the remainder is the result of the Remainder method on the two operands.

Exceptions:

### DivRem

public static PeterO.Numbers.EInteger DivRem(
    PeterO.Numbers.EInteger dividend,
    PeterO.Numbers.EInteger divisor,
    PeterO.Numbers.EInteger& remainder);

Deprecated. Use the DivRem instance method instead.

Divides this arbitrary-precision integer by another arbitrary-precision integer and returns a two-item array containing the result of the division and the remainder, in that order. The result of the division is rounded down (the fractional part is discarded). Except if the result of the division is 0, it will be negative if this arbitrary-precision integer is positive and the other arbitrary-precision integer is negative, or vice versa, and will be positive if both are positive or both are negative. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other arbitrary-precision integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

An array of two items: the first is the result of the division as an arbitrary-precision integer, and the second is the remainder as an arbitrary-precision integer. The result of division is the result of the Divide method on the two operands, and the remainder is the result of the Remainder method on the two operands.

Exceptions:

### Equals

public override bool Equals(
    object obj);

Determines whether this object and another object are equal and have the same type.

Parameters:

Return Value:

true if this object and another object are equal; otherwise, false .

### Equals

public sealed bool Equals(
    PeterO.Numbers.EInteger other);

Determines whether this object and another object are equal.

Parameters:

Return Value:

true if this object and another object are equal; otherwise, false .

### Eqv

public PeterO.Numbers.EInteger Eqv(
    PeterO.Numbers.EInteger second);

Does an XOR NOT operation (or equivalence operation, EQV operation, or exclusive-OR NOT operation) between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set or the other integer’s corresponding bit is not set, but not both. For example, in binary, 10110 XOR NOT 11010 = 10011 (or in decimal, 22 XOR NOT 26 = 19). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101110 XOR NOT 01011 = …11111010 (or in decimal, -18 OR 11 = -6).

Exceptions:

### FromBoolean

public static PeterO.Numbers.EInteger FromBoolean(
    bool boolValue);

Converts a boolean value (true or false) to an arbitrary-precision integer.

Parameters:

Return Value:

The number 1 if boolValue is true; otherwise, 0.

### FromByte

public static PeterO.Numbers.EInteger FromByte(
    byte inputByte);

Converts a byte (from 0 to 255) to an arbitrary-precision integer.

Parameters:

Return Value:

This number’s value as an arbitrary-precision integer.

### FromBytes

public static PeterO.Numbers.EInteger FromBytes(
    byte[] bytes,
    bool littleEndian);

Initializes an arbitrary-precision integer from an array of bytes.

Parameters:

Return Value:

An arbitrary-precision integer. Returns 0 if the byte array’s length is 0.

Exceptions:

### FromBytes

public static PeterO.Numbers.EInteger FromBytes(
    byte[] bytes,
    int offset,
    int length,
    bool littleEndian);

Initializes an arbitrary-precision integer from a portion of an array of bytes. The portion of the byte array is encoded using the following rules:

For little-endian, the byte order is reversed from the byte order just discussed.

Parameters:

Return Value:

An arbitrary-precision integer. Returns 0 if the byte array’s length is 0.

Exceptions:

### FromInt16

public static PeterO.Numbers.EInteger FromInt16(
    short inputInt16);

Converts a 16-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

This number’s value as an arbitrary-precision integer.

### FromInt32

public static PeterO.Numbers.EInteger FromInt32(
    int intValue);

Converts a 32-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as the 64-bit number.

### FromInt64

public static PeterO.Numbers.EInteger FromInt64(
    long longerValue);

Converts a 64-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as the 64-bit number.

### FromInt64AsUnsigned

public static PeterO.Numbers.EInteger FromInt64AsUnsigned(
    long longerValue);

Converts an unsigned integer expressed as a 64-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer. If longerValue is 0 or greater, the return value will represent it. If longerValue is less than 0, the return value will store 2^64 plus this value instead.

### FromRadixString

public static PeterO.Numbers.EInteger FromRadixString(
    byte[] bytes,
    int radix);

Converts a sequence of bytes (interpreted as text) to an arbitrary-precision integer in a given radix. Each byte in the sequence has to be a character in the Basic Latin range (0x00 to 0x7f or U+0000 to U+007F) of the Unicode Standard.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as the given sequence of bytes.

Exceptions:

### FromRadixString

public static PeterO.Numbers.EInteger FromRadixString(
    char[] cs,
    int radix);

Converts a sequence of char s to an arbitrary-precision integer in a given radix.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as the given sequence of char s.

Exceptions:

### FromRadixString

public static PeterO.Numbers.EInteger FromRadixString(
    string str,
    int radix);

Converts a string to an arbitrary-precision integer in a given radix.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as the given string.

Exceptions:

### FromRadixSubstring

public static PeterO.Numbers.EInteger FromRadixSubstring(
    byte[] bytes,
    int radix,
    int index,
    int endIndex);

Converts a portion of a sequence of bytes (interpreted as text) to an arbitrary-precision integer in a given radix. Each byte in the sequence has to be a character in the Basic Latin range (0x00 to 0x7f or U+0000 to U+007F) of the Unicode Standard.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the sequence’s portion.

Exceptions:

### FromRadixSubstring

public static PeterO.Numbers.EInteger FromRadixSubstring(
    char[] cs,
    int radix,
    int index,
    int endIndex);

Converts a portion of a sequence of char s to an arbitrary-precision integer in a given radix.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the sequence’s portion.

Exceptions:

### FromRadixSubstring

public static PeterO.Numbers.EInteger FromRadixSubstring(
    string str,
    int radix,
    int index,
    int endIndex);

Converts a portion of a string to an arbitrary-precision integer in a given radix.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the string portion.

Exceptions:

### FromSByte

public static PeterO.Numbers.EInteger FromSByte(
    sbyte inputSByte);

This API is not CLS-compliant.

Converts an 8-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

This number’s value as an arbitrary-precision integer.

### FromString

public static PeterO.Numbers.EInteger FromString(
    byte[] bytes);

Converts a sequence of bytes (interpreted as text) to an arbitrary-precision integer. Each byte in the sequence has to be a code point in the Basic Latin range (0x00 to 0x7f or U+0000 to U+007F) of the Unicode Standard.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the sequence of bytes.

Exceptions:

### FromString

public static PeterO.Numbers.EInteger FromString(
    char[] cs);

Converts a sequence of char s to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the sequence of char s.

Exceptions:

### FromString

public static PeterO.Numbers.EInteger FromString(
    string str);

Converts a string to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the string.

Exceptions:

### FromSubstring

public static PeterO.Numbers.EInteger FromSubstring(
    byte[] bytes,
    int index,
    int endIndex);

Converts a portion of a sequence of bytes (interpreted as text) to an arbitrary-precision integer. Each byte in the sequence has to be a character in the Basic Latin range (0x00 to 0x7f or U+0000 to U+007F) of the Unicode Standard.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the sequence of bytes (interpreted as text) portion.

Exceptions:

### FromSubstring

public static PeterO.Numbers.EInteger FromSubstring(
    char[] cs,
    int index,
    int endIndex);

Converts a portion of a sequence of char s to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the sequence of char s portion.

Exceptions:

### FromSubstring

public static PeterO.Numbers.EInteger FromSubstring(
    string str,
    int index,
    int endIndex);

Converts a portion of a string to an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer with the same value as given in the string portion.

Exceptions:

### FromUInt16

public static PeterO.Numbers.EInteger FromUInt16(
    ushort inputUInt16);

This API is not CLS-compliant.

Converts a 16-bit unsigned integer to an arbitrary-precision integer.

Parameters:

Return Value:

This number’s value as an arbitrary-precision integer.

### FromUInt32

public static PeterO.Numbers.EInteger FromUInt32(
    uint inputUInt32);

This API is not CLS-compliant.

Converts a 32-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

This number’s value as an arbitrary-precision integer.

### FromUInt64

public static PeterO.Numbers.EInteger FromUInt64(
    ulong ulongValue);

This API is not CLS-compliant.

Converts a 64-bit unsigned integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of ulongValue as an arbitrary-precision integer.

### Gcd

public PeterO.Numbers.EInteger Gcd(
    PeterO.Numbers.EInteger bigintSecond);

Returns the greatest common divisor of this integer and the given integer. The greatest common divisor (GCD) is also known as the greatest common factor (GCF). This method works even if either or both integers are negative.

Parameters:

Return Value:

The greatest common divisor of this integer and the given integer.

Exceptions:

### GetBits

public long GetBits(
    int index,
    int numberBits);

Retrieves bits from this integer’s two’s-complement form.

Parameters:

Return Value:

A 64-bit signed integer containing the bits from this integer’s two’s-complement form. The least significant bit is the first bit, and any unused bits are set to 0.

### GetDigitCount

public int GetDigitCount();

Deprecated. This method may overflow. Use GetDigitCountAsEInteger instead.

Returns the number of decimal digits used by this integer.

Return Value:

The number of digits in the decimal form of this integer. Returns 1 if this number is 0.

Exceptions:

### GetDigitCountAsEInteger

public PeterO.Numbers.EInteger GetDigitCountAsEInteger();

Returns the number of decimal digits used by this integer, in the form of an arbitrary-precision integer.

Return Value:

The number of digits in the decimal form of this integer. Returns 1 if this number is 0.

### GetDigitCountAsInt64

public long GetDigitCountAsInt64();

Returns the number of decimal digits used by this integer, in the form of a 64-bit signed integer.

Return Value:

The number of digits in the decimal form of this integer. Returns 1 if this number is 0. Returns 2^63 - 1( Int64.MaxValue in.NET or Long.MAX_VALUE in Java) if the number of decimal digits is 2^63 - 1 or greater. (Use GetDigitCountAsEInteger instead if the application relies on the exact number of decimal digits.).

### 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.

### GetLowBit

public int GetLowBit();

Deprecated. This method may overflow. Use GetLowBitAsEInteger instead.

Gets the bit position of the lowest set bit in this number’s absolute value. (This will also be the position of the lowest set bit in the number’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ).).

Return Value:

The bit position of the lowest bit set in the number’s absolute value, starting at 0. Returns -1 if this value is 0.

### GetLowBitAsEInteger

public PeterO.Numbers.EInteger GetLowBitAsEInteger();

Gets the bit position of the lowest set bit in this number’s absolute value, in the form of an arbitrary-precision integer. (This will also be the position of the lowest set bit in the number’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ).).

Return Value:

The bit position of the lowest bit set in the number’s absolute value, starting at 0. Returns -1 if this value is 0 or odd.

### GetLowBitAsInt64

public long GetLowBitAsInt64();

Gets the bit position of the lowest set bit in this number’s absolute value, in the form of a 64-bit signed integer. (This will also be the position of the lowest set bit in the number’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ).).

Return Value:

The bit position of the lowest bit set in the number’s absolute value, starting at 0. Returns -1 if this value is 0 or odd. Returns 2^63 - 1 ( Int64.MaxValue in.NET or Long.MAX_VALUE in Java) if this number is other than zero but the lowest set bit is at 2^63 - 1 or greater. (Use GetLowBitAsEInteger instead if the application relies on the exact value of the lowest set bit position.).

### GetSignedBit

public bool GetSignedBit(
    int index);

Returns whether a bit is set in the two’s-complement form (see "Forms of numbers"“Forms of numbers” ) of this object’s value.

Parameters:

Return Value:

true if the given bit is set in the two’ s-complement form (see "Forms of numbers"“Forms of numbers” ) of this object’s value; otherwise, false .

### GetSignedBit

public bool GetSignedBit(
    PeterO.Numbers.EInteger bigIndex);

Returns whether a bit is set in the two’s-complement form (see "Forms of numbers"“Forms of numbers” ) of this object’s value.

Parameters:

Return Value:

true if the given bit is set in the two’ s-complement form (see "Forms of numbers"“Forms of numbers” ) of this object’s value; otherwise, false .

Exceptions:

### GetSignedBitLength

public int GetSignedBitLength();

Deprecated. This method may overflow. Use GetSignedBitLengthAsEInteger instead.

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 the value equal to this object’s absolute value minus 1. For example, all integers in the interval [-(2^63), (2^63) - 1], which is the same as the range of integers in Java’s and.NET’s long type, have a signed bit length of 63 or less, and all other integers have a signed bit length of greater than 63.

Return Value:

The number of bits in this object’s value, except for its sign. Returns 0 if this object’s value is 0 or negative 1.

Exceptions:

### GetSignedBitLengthAsEInteger

public PeterO.Numbers.EInteger GetSignedBitLengthAsEInteger();

Finds the minimum number of bits needed to represent this object’s value, except for its sign, and returns that number of bits as an arbitrary-precision integer. If the value is negative, finds the number of bits in the value equal to this object’s absolute value minus 1. For example, all integers in the interval [-(2^63), (2^63) - 1], which is the same as the range of integers in Java’s and.NET’s long type, have a signed bit length of 63 or less, and all other integers have a signed bit length of greater than 63.

Return Value:

The number of bits in this object’s value, except for its sign. Returns 0 if this object’s value is 0 or negative 1.

### GetSignedBitLengthAsInt64

public long GetSignedBitLengthAsInt64();

Finds the minimum number of bits needed to represent this object’s value, except for its sign, and returns that number of bits as a 64-bit signed integer. If the value is negative, finds the number of bits in the value equal to this object’s absolute value minus 1. For example, all integers in the interval [-(2^63), (2^63) - 1], which is the same as the range of integers in Java’s and.NET’s long type, have a signed bit length of 63 or less, and all other integers have a signed bit length of greater than 63.

Return Value:

The number of bits in this object’s value, except for its sign. Returns 0 if this object’s value is 0 or negative 1. If the return value would be greater than 2^63 - 1 ( Int64.MaxValue in.NET or Long.MAX_VALUE in Java), returns 2^63 - 1 instead. (Use GetSignedBitLengthAsEInteger instead of this method if the application relies on the exact number of bits.).

### GetUnsignedBit

public bool GetUnsignedBit(
    int index);

Returns whether a bit is set in this number’s absolute value.

Parameters:

Return Value:

true if the given bit is set in this number’s absolute value.

### GetUnsignedBit

public bool GetUnsignedBit(
    PeterO.Numbers.EInteger bigIndex);

Returns whether a bit is set in this number’s absolute value.

Parameters:

Return Value:

true if the given bit is set in this number’s absolute value.

Exceptions:

### GetUnsignedBitLength

public int GetUnsignedBitLength();

Deprecated. This method may overflow. Use GetUnsignedBitLengthAsEInteger instead.

Finds the minimum number of bits needed to represent this number’s absolute value. For example, all integers in the interval [-((2^63) - 1), (2^63) - 1] have an unsigned bit length of 63 or less, and all other integers have an unsigned bit length of greater than 63. This interval is not the same as the range of integers in Java’s and.NET’s long type.

Return Value:

The number of bits in this object’s absolute value. Returns 0 if this object’s value is 0, and returns 1 if the value is negative 1.

Exceptions:

### GetUnsignedBitLengthAsEInteger

public PeterO.Numbers.EInteger GetUnsignedBitLengthAsEInteger();

Finds the minimum number of bits needed to represent this number’s absolute value, and returns that number of bits as an arbitrary-precision integer. For example, all integers in the interval [-((2^63) - 1), (2^63) - 1] have an unsigned bit length of 63 or less, and all other integers have an unsigned bit length of greater than 63. This interval is not the same as the range of integers in Java’s and.NET’s long type.

Return Value:

The number of bits in this object’s absolute value. Returns 0 if this object’s value is 0, and returns 1 if the value is negative 1.

### GetUnsignedBitLengthAsInt64

public long GetUnsignedBitLengthAsInt64();

Finds the minimum number of bits needed to represent this number’s absolute value, and returns that number of bits as a 64-bit signed integer. For example, all integers in the interval [-((2^63) - 1), (2^63) - 1] have an unsigned bit length of 63 or less, and all other integers have an unsigned bit length of greater than 63. This interval is not the same as the range of integers in Java’s and.NET’s long type.

Return Value:

The number of bits in this object’s absolute value. Returns 0 if this object’s value is 0, and returns 1 if the value is negative 1. If the return value would be greater than 2^63 - 1( Int64.MaxValue in.NET or Long.MAX_VALUE in Java), returns 2^63 - 1 instead. (Use GetUnsignedBitLengthAsEInteger instead of this method if the application relies on the exact number of bits.).

### Imp

public PeterO.Numbers.EInteger Imp(
    PeterO.Numbers.EInteger second);

Deprecated. Does the incorrect implication operation. Use Imply instead.

Does an OR NOT operation between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set, the other integer’s corresponding bit is not set, or both. For example, in binary, 10110 OR NOT 11010 = 00100 (or in decimal, 22 OR NOT 26 = 23). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101110 OR NOT 01011 = …11111110 (or in decimal, -18 OR 11 = -2).

Exceptions:

### Increment

public PeterO.Numbers.EInteger Increment();

Returns one added to this arbitrary-precision integer.

Return Value:

The given arbitrary-precision integer plus one.

### LowBits

public PeterO.Numbers.EInteger LowBits(
    int bitCount);

Extracts the lowest bits of this integer. This is equivalent to And(2^bitCount - 1) , but is more efficient when this integer is non-negative and bitCount’s value is large.

Parameters:

Return Value:

A value equivalent to And(2^bitCount - 1) .

### LowBits

public PeterO.Numbers.EInteger LowBits(
    long longBitCount);

Extracts the lowest bits of this integer. This is equivalent to And(2^longBitCount - 1) , but is more efficient when this integer is non-negative and longBitCount’s value is large.

Parameters:

Return Value:

A value equivalent to And(2^longBitCount - 1) .

### LowBits

public PeterO.Numbers.EInteger LowBits(
    PeterO.Numbers.EInteger bigBitCount);

Extracts the lowest bits of this integer. This is equivalent to And(2^bigBitCount - 1) , but is more efficient when this integer is non-negative and bigBitCount’s value is large.

Parameters:

Return Value:

A value equivalent to And(2^bigBitCount - 1) .

Exceptions:

### Max

public static PeterO.Numbers.EInteger Max(
    PeterO.Numbers.EInteger first,
    PeterO.Numbers.EInteger second);

Returns the greater of two arbitrary-precision integers.

Parameters:

Return Value:

The greater of the two integers.

Exceptions:

### MaxMagnitude

public static PeterO.Numbers.EInteger MaxMagnitude(
    PeterO.Numbers.EInteger first,
    PeterO.Numbers.EInteger second);

Of two arbitrary-precision integers, returns the one with the greater absolute value. If both integers have the same absolute value, this method has the same effect as Max.

Parameters:

Return Value:

The integer with the greater absolute value.

Exceptions:

### Min

public static PeterO.Numbers.EInteger Min(
    PeterO.Numbers.EInteger first,
    PeterO.Numbers.EInteger second);

Returns the smaller of two arbitrary-precision integers.

Parameters:

Return Value:

The smaller of the two integers.

Exceptions:

### MinMagnitude

public static PeterO.Numbers.EInteger MinMagnitude(
    PeterO.Numbers.EInteger first,
    PeterO.Numbers.EInteger second);

Of two arbitrary-precision integers, returns the one with the smaller absolute value. If both integers have the same absolute value, this method has the same effect as Min.

Parameters:

Return Value:

The integer with the smaller absolute value.

Exceptions:

### Mod

public PeterO.Numbers.EInteger Mod(
    int smallDivisor);

Finds the modulus remainder that results when this instance is divided by the value of another integer. The modulus remainder is the same as the normal remainder if the normal remainder is positive, and equals divisor plus normal remainder if the normal remainder is negative.

Parameters:

Return Value:

The modulus remainder.

Exceptions:

### Mod

public PeterO.Numbers.EInteger Mod(
    PeterO.Numbers.EInteger divisor);

Finds the modulus remainder that results when this instance is divided by the value of an arbitrary-precision integer. The modulus remainder is the same as the normal remainder if the normal remainder is positive, and equals divisor plus normal remainder if the normal remainder is negative.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### ModPow

public PeterO.Numbers.EInteger ModPow(
    PeterO.Numbers.EInteger pow,
    PeterO.Numbers.EInteger mod);

Calculates the remainder when this arbitrary-precision integer raised to a certain power is divided by another arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### ModPow

public static PeterO.Numbers.EInteger ModPow(
    PeterO.Numbers.EInteger bigintValue,
    PeterO.Numbers.EInteger pow,
    PeterO.Numbers.EInteger mod);

Calculates the remainder when an arbitrary-precision integer raised to a certain power is divided by another arbitrary-precision integer.

Parameters:

Return Value:

The value ( bigintValue ^ pow )% mod .

Exceptions:

### Multiply

public PeterO.Numbers.EInteger Multiply(
    int intValue);

Multiplies this arbitrary-precision integer by a 32-bit signed integer and returns the result.

EInteger result = EInteger.FromString("5").Multiply(200);

.

Parameters:

Return Value:

The product of the two numbers, that is, this arbitrary-precision integer times a 32-bit signed integer.

### Multiply

public PeterO.Numbers.EInteger Multiply(
    long longValue);

Multiplies this arbitrary-precision integer by a 64-bit signed integer and returns the result.

Parameters:

Return Value:

The product of the two numbers, that is, this arbitrary-precision integer times a 64-bit signed integer.

### Multiply

public PeterO.Numbers.EInteger Multiply(
    PeterO.Numbers.EInteger bigintMult);

Multiplies this arbitrary-precision integer by another arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The product of the two numbers, that is, this arbitrary-precision integer times another arbitrary-precision integer.

Exceptions:

### Negate

public PeterO.Numbers.EInteger Negate();

Gets the value of this object with the sign reversed.

Return Value:

This object’s value with the sign reversed.

### Not

public PeterO.Numbers.EInteger Not();

Returns an arbitrary-precision integer with every bit flipped from this one (also called an inversion or NOT operation).

Return Value:

An arbitrary-precision integer in which each bit in its two’s complement representation is set if the corresponding bit of this integer is clear, and vice versa. Returns -1 if this integer is 0. If this integer is positive, the return value is negative, and vice versa. This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, NOT 10100 = …11101011 (or in decimal, NOT 20 = -21). In binary, NOT …11100110 = 11001 (or in decimal, NOT -26 = 25).

### Not

public static PeterO.Numbers.EInteger Not(
    PeterO.Numbers.EInteger valueA);

Returns an arbitrary-precision integer with every bit flipped.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Operator +

public static PeterO.Numbers.EInteger operator +(
    PeterO.Numbers.EInteger bthis,
    PeterO.Numbers.EInteger augend);

Adds an arbitrary-precision integer and another arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The sum of the two numbers, that is, an arbitrary-precision integer plus another arbitrary-precision integer.

Exceptions:

### Operator &

public static PeterO.Numbers.EInteger operator &(
    PeterO.Numbers.EInteger thisValue,
    PeterO.Numbers.EInteger otherValue);

Does an AND operation between two arbitrary-precision integer values. For each bit of the result, that bit is 1 if the corresponding bits of the two operands are both 1, or is 0 otherwise.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

The result of the operation.

Exceptions:

### Operator |

public static PeterO.Numbers.EInteger operator |(
    PeterO.Numbers.EInteger thisValue,
    PeterO.Numbers.EInteger otherValue);

Does an OR operation between two arbitrary-precision integer instances. For each bit of the result, that bit is 1 if either or both of the corresponding bits of the two operands are 1, or is 0 otherwise.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

The result of the operation.

Exceptions:

### Operator --

public static PeterO.Numbers.EInteger operator --(
    PeterO.Numbers.EInteger bthis);

Subtracts one from an arbitrary-precision integer.

Parameters:

Return Value:

The given arbitrary-precision integer minus one.

Exceptions:

### Operator /

public static PeterO.Numbers.EInteger operator /(
    PeterO.Numbers.EInteger dividend,
    PeterO.Numbers.EInteger divisor);

Divides an arbitrary-precision integer by the value of an arbitrary-precision integer object.

Parameters:

Return Value:

The quotient of the two objects.

Exceptions:

### Operator ^

public static PeterO.Numbers.EInteger operator ^(
    PeterO.Numbers.EInteger a,
    PeterO.Numbers.EInteger b);

Finds the exclusive “or” of two arbitrary-precision integer objects. For each bit of the result, that bit is 1 if either of the corresponding bits of the two operands, but not both, is 1, or is 0 otherwise. Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if it’s set in one input integer but not the other.

Exceptions:

### Explicit Operator

public static explicit operator byte(
    PeterO.Numbers.EInteger input);

Converts an arbitrary-precision integer to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255).

Parameters:

Return Value:

The value of input as a byte (from 0 to 255).

Exceptions:

### Explicit Operator

public static explicit operator int(
    PeterO.Numbers.EInteger input);

Converts an arbitrary-precision integer to a 32-bit signed integer if it can fit in a 32-bit signed integer.

Parameters:

Return Value:

The value of input as a 32-bit signed integer.

Exceptions:

### Explicit Operator

public static explicit operator long(
    PeterO.Numbers.EInteger input);

Converts an arbitrary-precision integer to a 64-bit signed integer if it can fit in a 64-bit signed integer.

Parameters:

Return Value:

The value of input as a 64-bit signed integer.

Exceptions:

### Explicit Operator

public static explicit operator PeterO.Numbers.EInteger(
    bool boolValue);

Converts a byte (from 0 to 255) to an arbitrary-precision integer.

Parameters:

Return Value:

The value of boolValue as an arbitrary-precision integer.

### Explicit Operator

public static explicit operator sbyte(
    PeterO.Numbers.EInteger input);

This API is not CLS-compliant.

Converts an arbitrary-precision integer to an 8-bit signed integer if it can fit in an 8-bit signed integer.

Parameters:

Return Value:

The value of input as an 8-bit signed integer.

Exceptions:

### Explicit Operator

public static explicit operator short(
    PeterO.Numbers.EInteger input);

Converts an arbitrary-precision integer to a 16-bit signed integer if it can fit in a 16-bit signed integer.

Parameters:

Return Value:

The value of input as a 16-bit signed integer.

Exceptions:

### Explicit Operator

public static explicit operator uint(
    PeterO.Numbers.EInteger input);

This API is not CLS-compliant.

Converts an arbitrary-precision integer to a 32-bit signed integer if it can fit in a 32-bit signed integer.

Parameters:

Return Value:

The value of input as a 32-bit signed integer.

Exceptions:

### Explicit Operator

public static explicit operator ulong(
    PeterO.Numbers.EInteger input);

This API is not CLS-compliant.

Converts an arbitrary-precision integer to a 64-bit unsigned integer if it can fit in a 64-bit unsigned integer.

Parameters:

Return Value:

The value of input as a 64-bit unsigned integer.

Exceptions:

### Explicit Operator

public static explicit operator ushort(
    PeterO.Numbers.EInteger input);

This API is not CLS-compliant.

Converts an arbitrary-precision integer to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer.

Parameters:

Return Value:

The value of input as a 16-bit unsigned integer.

Exceptions:

### Operator >

public static bool operator >(
    PeterO.Numbers.EInteger thisValue,
    PeterO.Numbers.EInteger otherValue);

Determines whether an arbitrary-precision integer is greater than another arbitrary-precision integer.

Parameters:

Return Value:

true if thisValue is greater than otherValue ; otherwise, false .

### Operator >=

public static bool operator >=(
    PeterO.Numbers.EInteger thisValue,
    PeterO.Numbers.EInteger otherValue);

Determines whether an arbitrary-precision integer value is greater than another arbitrary-precision integer.

Parameters:

Return Value:

true if thisValue is at least otherValue ; otherwise, false .

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    byte inputByte);

Converts a byte (from 0 to 255) to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputByte as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    int inputInt32);

Converts a 32-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputInt32 as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    long inputInt64);

Converts a 64-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputInt64 as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    sbyte inputSByte);

This API is not CLS-compliant.

Converts an 8-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputSByte as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    short inputInt16);

Converts a 16-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputInt16 as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    uint inputUInt32);

This API is not CLS-compliant.

Converts a 32-bit signed integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputUInt32 as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    ulong inputUInt64);

This API is not CLS-compliant.

Converts a 64-bit unsigned integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputUInt64 as an arbitrary-precision integer.

### Implicit Operator

public static implicit operator PeterO.Numbers.EInteger(
    ushort inputUInt16);

This API is not CLS-compliant.

Converts a 16-bit unsigned integer to an arbitrary-precision integer.

Parameters:

Return Value:

The value of inputUInt16 as an arbitrary-precision integer.

### Operator ++

public static PeterO.Numbers.EInteger operator ++(
    PeterO.Numbers.EInteger bthis);

Adds one to an arbitrary-precision integer.

Parameters:

Return Value:

The given arbitrary-precision integer plus one.

Exceptions:

### Operator <<

public static PeterO.Numbers.EInteger operator <<(
    PeterO.Numbers.EInteger bthis,
    int bitCount);

Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Operator <

public static bool operator <(
    PeterO.Numbers.EInteger thisValue,
    PeterO.Numbers.EInteger otherValue);

Determines whether an arbitrary-precision integer is less than another arbitrary-precision integer.

Parameters:

Return Value:

true if thisValue is less than otherValue ; otherwise, false .

### Operator <=

public static bool operator <=(
    PeterO.Numbers.EInteger thisValue,
    PeterO.Numbers.EInteger otherValue);

Determines whether an arbitrary-precision integer is up to another arbitrary-precision integer.

Parameters:

Return Value:

true if thisValue is up to otherValue ; otherwise, false .

### Operator %

public static PeterO.Numbers.EInteger operator %(
    PeterO.Numbers.EInteger dividend,
    PeterO.Numbers.EInteger divisor);

Returns the remainder that would result when an arbitrary-precision integer is divided by another arbitrary-precision integer. The remainder is the number that remains when the absolute value of an arbitrary-precision integer is divided by the absolute value of the other arbitrary-precision integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

The remainder that would result when an arbitrary-precision integer is divided by another arbitrary-precision integer.

Exceptions:

### Operator *

public static PeterO.Numbers.EInteger operator *(
    PeterO.Numbers.EInteger operand1,
    PeterO.Numbers.EInteger operand2);

Multiplies an arbitrary-precision integer by another arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The product of the two numbers, that is, an arbitrary-precision integer times another arbitrary-precision integer.

Exceptions:

### Operator ~

public static PeterO.Numbers.EInteger operator ~(
    PeterO.Numbers.EInteger thisValue);

Returns an arbitrary-precision integer with every bit flipped.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Operator >>

public static PeterO.Numbers.EInteger operator >>(
    PeterO.Numbers.EInteger bthis,
    int smallValue);

Shifts the bits of an arbitrary-precision integer to the right.

For this operation, the arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ). Thus, for negative values, the arbitrary-precision integer is sign-extended.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Operator -

public static PeterO.Numbers.EInteger operator -(
    PeterO.Numbers.EInteger bthis,
    PeterO.Numbers.EInteger subtrahend);

Subtracts two arbitrary-precision integer values.

Parameters:

Return Value:

The difference of the two objects.

Exceptions:

### Operator -

public static PeterO.Numbers.EInteger operator -(
    PeterO.Numbers.EInteger bigValue);

Negates an arbitrary-precision integer.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Or

public PeterO.Numbers.EInteger Or(
    PeterO.Numbers.EInteger second);

Does an OR operation between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set, the other integer’s corresponding bit is set, or both. For example, in binary, 10110 OR 11010 = 11110 (or in decimal, 22 OR 26 = 30). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101110 OR 01011 = …11101111 (or in decimal, -18 OR 11 = -17).

Exceptions:

### Or

public static PeterO.Numbers.EInteger Or(
    PeterO.Numbers.EInteger first,
    PeterO.Numbers.EInteger second);

Does an OR operation between two arbitrary-precision integer instances.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### OrNot

public PeterO.Numbers.EInteger OrNot(
    PeterO.Numbers.EInteger second);

Does an OR NOT operation between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set, the other integer’s corresponding bit is not set, or both. For example, in binary, 10110 OR NOT 11010 = 00100 (or in decimal, 22 OR NOT 26 = 23). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101110 OR NOT 01011 = …11111110 (or in decimal, -18 OR 11 = -2).

Exceptions:

### Pow

public PeterO.Numbers.EInteger Pow(
    int powerSmall);

Raises an arbitrary-precision integer to a power.

Parameters:

Return Value:

The result. Returns 1 if powerSmall is 0.

### Pow

public PeterO.Numbers.EInteger Pow(
    long longPower);

Raises an arbitrary-precision integer to a power.

Parameters:

Return Value:

The result. Returns 1 if longPower is 0.

Exceptions:

### Pow

public PeterO.Numbers.EInteger Pow(
    PeterO.Numbers.EInteger bigPower);

Raises an arbitrary-precision integer to a power.

Parameters:

Return Value:

The result. Returns 1 if bigPower is 0.

Exceptions:

### PowBigIntVar

public PeterO.Numbers.EInteger PowBigIntVar(
    PeterO.Numbers.EInteger power);

Deprecated. Use Pow instead.

Raises an arbitrary-precision integer to a power, which is given as another arbitrary-precision integer.

Parameters:

Return Value:

The result. Returns 1 if power is 0.

Exceptions:

### Remainder

public PeterO.Numbers.EInteger Remainder(
    int intValue);

Returns the remainder that would result when this arbitrary-precision integer is divided by a 32-bit signed integer. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other 32-bit signed integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

The remainder that would result when this arbitrary-precision integer is divided by a 32-bit signed integer.

Exceptions:

### Remainder

public PeterO.Numbers.EInteger Remainder(
    long longValue);

Returns the remainder that would result when this arbitrary-precision integer is divided by a 64-bit signed integer. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other 64-bit signed integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

The remainder that would result when this arbitrary-precision integer is divided by a 64-bit signed integer.

### Remainder

public PeterO.Numbers.EInteger Remainder(
    PeterO.Numbers.EInteger divisor);

Returns the remainder that would result when this arbitrary-precision integer is divided by another arbitrary-precision integer. The remainder is the number that remains when the absolute value of this arbitrary-precision integer is divided by the absolute value of the other arbitrary-precision integer; the remainder has the same sign (positive or negative) as this arbitrary-precision integer.

Parameters:

Return Value:

The remainder that would result when this arbitrary-precision integer is divided by another arbitrary-precision integer.

Exceptions:

### Root

public PeterO.Numbers.EInteger Root(
    int root);

Finds the nth root of this instance’s value, rounded down.

Parameters:

Return Value:

The square root of this object’s value. Returns 0 if this value is 0 or less.

### Root

public PeterO.Numbers.EInteger Root(
    PeterO.Numbers.EInteger root);

Finds the nth root of this instance’s value, rounded down.

Parameters:

Return Value:

The square root of this object’s value. Returns 0 if this value is 0 or less.

Exceptions:

### RootRem

public PeterO.Numbers.EInteger[] RootRem(
    int root);

Calculates the nth root and the remainder.

Parameters:

Return Value:

An array of two arbitrary-precision integers: the first integer is the nth root, and the second is the difference between this value and the nth power of the first integer. Returns two zeros if this value is 0 or less, or one and zero if this value equals 1.

### RootRem

public PeterO.Numbers.EInteger[] RootRem(
    PeterO.Numbers.EInteger root);

Calculates the nth root and the remainder.

Parameters:

Return Value:

An array of two arbitrary-precision integers: the first integer is the nth root, and the second is the difference between this value and the nth power of the first integer. Returns two zeros if this value is 0 or less, or one and zero if this value equals 1.

Exceptions:

### ShiftLeft

public PeterO.Numbers.EInteger ShiftLeft(
    int numberBits);

Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on.

Parameters:

Return Value:

An arbitrary-precision integer.

### ShiftLeft

public PeterO.Numbers.EInteger ShiftLeft(
    PeterO.Numbers.EInteger eshift);

Returns an arbitrary-precision integer with the bits shifted to the left by a number of bits given as an arbitrary-precision integer. A value of 1 doubles this value, a value of 2 multiplies it by 4, a value of 3 by 8, a value of 4 by 16, and so on.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### ShiftRight

public PeterO.Numbers.EInteger ShiftRight(
    int numberBits);

Returns an arbitrary-precision integer with the bits shifted to the right. For this operation, the arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ). Thus, for negative values, the arbitrary-precision integer is sign-extended.

Parameters:

Return Value:

An arbitrary-precision integer.

### ShiftRight

public PeterO.Numbers.EInteger ShiftRight(
    PeterO.Numbers.EInteger eshift);

Returns an arbitrary-precision integer with the bits shifted to the right. For this operation, the arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ). Thus, for negative values, the arbitrary-precision integer is sign-extended.

Parameters:

Return Value:

An arbitrary-precision integer.

Exceptions:

### Sqrt

public PeterO.Numbers.EInteger Sqrt();

Finds the square root of this instance’s value, rounded down.

Return Value:

The square root of this object’s value. Returns 0 if this value is 0 or less.

### SqrtRem

public PeterO.Numbers.EInteger[] SqrtRem();

Calculates the square root and the remainder.

Return Value:

An array of two arbitrary-precision integers: the first integer is the square root, and the second is the difference between this value and the square of the first integer. Returns two zeros if this value is 0 or less, or one and zero if this value equals 1.

### Subtract

public PeterO.Numbers.EInteger Subtract(
    int intValue);

Subtracts a 32-bit signed integer from this arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The difference between the two numbers, that is, this arbitrary-precision integer minus a 32-bit signed integer.

### Subtract

public PeterO.Numbers.EInteger Subtract(
    long longValue);

Subtracts a 64-bit signed integer from this arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The difference between the two numbers, that is, this arbitrary-precision integer minus a 64-bit signed integer.

### Subtract

public PeterO.Numbers.EInteger Subtract(
    PeterO.Numbers.EInteger subtrahend);

Subtracts an arbitrary-precision integer from this arbitrary-precision integer and returns the result.

Parameters:

Return Value:

The difference between the two numbers, that is, this arbitrary-precision integer minus another arbitrary-precision integer.

Exceptions:

### ToByteChecked

public byte ToByteChecked();

Converts this number’s value to a byte (from 0 to 255) if it can fit in a byte (from 0 to 255).

Return Value:

This number’s value as a byte (from 0 to 255).

Exceptions:

### ToBytes

public byte[] ToBytes(
    bool littleEndian);

Returns a byte array of this integer’s value. The byte array will take the number’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ), using the fewest bytes necessary to store its value unambiguously. If this value is negative, the bits that appear beyond the most significant bit of the number will be all ones. The resulting byte array can be passed to the FromBytes() method (with the same byte order) to reconstruct this integer’s value.

Parameters:

Return Value:

A byte array. If this value is 0, returns a byte array with the single element 0.

### ToByteUnchecked

public byte ToByteUnchecked();

Converts this number to a byte (from 0 to 255), returning the least-significant bits of this number’s two’s-complement form.

Return Value:

This number, converted to a byte (from 0 to 255).

### ToInt16Checked

public short ToInt16Checked();

Converts this number’s value to a 16-bit signed integer if it can fit in a 16-bit signed integer.

Return Value:

This number’s value as a 16-bit signed integer.

Exceptions:

### ToInt16Unchecked

public short ToInt16Unchecked();

Converts this number to a 16-bit signed integer, returning the least-significant bits of this number’s two’s-complement form.

Return Value:

This number, converted to a 16-bit signed integer.

### ToInt32Checked

public int ToInt32Checked();

Converts this object’s value to a 32-bit signed integer, throwing an exception if it can’t fit.

Return Value:

A 32-bit signed integer.

Exceptions:

### ToInt32Unchecked

public int ToInt32Unchecked();

Converts this object’s value to a 32-bit signed integer. If the value can’t fit in a 32-bit integer, returns the lower 32 bits of this object’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ) (in which case the return value might have a different sign than this object’s value).

Return Value:

A 32-bit signed integer.

### ToInt64Checked

public long ToInt64Checked();

Converts this object’s value to a 64-bit signed integer, throwing an exception if it can’t fit.

Return Value:

A 64-bit signed integer.

Exceptions:

### ToInt64Unchecked

public long ToInt64Unchecked();

Converts this object’s value to a 64-bit signed integer. If the value can’t fit in a 64-bit integer, returns the lower 64 bits of this object’s two’s-complement form (see "Forms of numbers"“Forms of numbers” ) (in which case the return value might have a different sign than this object’s value).

Return Value:

A 64-bit signed integer.

### ToRadixString

public string ToRadixString(
    int radix);

Generates a string representing the value of this object, in the given radix.

Parameters:

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 minus sign (“-“, U+002D). Depending on the radix, the string will use the basic digits 0 to 9 (U+0030 to U+0039) and then the basic upper-case 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.

### ToSByteChecked

public sbyte ToSByteChecked();

This API is not CLS-compliant.

Converts this number’s value to an 8-bit signed integer if it can fit in an 8-bit signed integer.

Return Value:

This number’s value as an 8-bit signed integer.

Exceptions:

### ToSByteUnchecked

public sbyte ToSByteUnchecked();

This API is not CLS-compliant.

Converts this number to an 8-bit signed integer, returning the least-significant bits of this number’s two’s-complement form.

Return Value:

This number, converted to an 8-bit signed integer.

### ToString

public override string ToString();

Converts this object to a text string in base 10.

Return Value:

A string representation of this object. If this value is 0, returns “0”. 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).

### ToUInt16Checked

public ushort ToUInt16Checked();

This API is not CLS-compliant.

Converts this number’s value to a 16-bit unsigned integer if it can fit in a 16-bit unsigned integer.

Return Value:

This number’s value as a 16-bit unsigned integer.

Exceptions:

### ToUInt16Unchecked

public ushort ToUInt16Unchecked();

This API is not CLS-compliant.

Converts this number to a 16-bit unsigned integer, returning the least-significant bits of this number’s two’s-complement form.

Return Value:

This number, converted to a 16-bit unsigned integer.

### ToUInt32Checked

public uint ToUInt32Checked();

This API is not CLS-compliant.

Converts this number’s value to a 32-bit signed integer if it can fit in a 32-bit signed integer.

Return Value:

This number’s value as a 32-bit signed integer.

Exceptions:

### ToUInt32Unchecked

public uint ToUInt32Unchecked();

This API is not CLS-compliant.

Converts this number to a 32-bit signed integer, returning the least-significant bits of this number’s two’s-complement form.

Return Value:

This number, converted to a 32-bit signed integer.

### ToUInt64Checked

public ulong ToUInt64Checked();

This API is not CLS-compliant.

Converts this number’s value to a 64-bit signed integer if it can fit in a 64-bit signed integer.

Return Value:

This number’s value as a 64-bit signed integer.

Exceptions:

### ToUInt64Unchecked

public ulong ToUInt64Unchecked();

This API is not CLS-compliant.

Converts this number to a 64-bit signed integer, returning the least-significant bits of this number’s two’s-complement form.

Return Value:

This number, converted to a 64-bit signed integer.

### Xor

public PeterO.Numbers.EInteger Xor(
    PeterO.Numbers.EInteger other);

Does an exclusive OR (XOR) operation between this arbitrary-precision integer and another one.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit is set in one input integer but not in the other. For example, in binary, 11010 XOR 01001 = 10011 (or in decimal, 26 XOR 9 = 19). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101101 XOR 00011 = …11101110 (or in decimal, -19 XOR 3 = -18).

Exceptions:

### Xor

public static PeterO.Numbers.EInteger Xor(
    PeterO.Numbers.EInteger a,
    PeterO.Numbers.EInteger b);

Finds the exclusive “or” of two arbitrary-precision integer objects. Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit is set in one input integer but not in the other.

Exceptions:

### XorNot

public PeterO.Numbers.EInteger XorNot(
    PeterO.Numbers.EInteger second);

Does an XOR NOT operation (or equivalence operation, EQV operation, or exclusive-OR NOT operation) between this arbitrary-precision integer and another one.

Each arbitrary-precision integer is treated as a two’s-complement form (see "Forms of numbers"“Forms of numbers” ) for the purposes of this operator.

Parameters:

Return Value:

An arbitrary-precision integer in which each bit is set if the corresponding bit of this integer is set or the other integer’s corresponding bit is not set, but not both. For example, in binary, 10110 XOR NOT 11010 = 10011 (or in decimal, 22 XOR NOT 26 = 19). This method uses the two’s complement form of negative integers (see "Forms of numbers"“Forms of numbers” ). For example, in binary, …11101110 XOR NOT 01011 = …11111010 (or in decimal, -18 OR 11 = -6).

Exceptions:

Back to Numbers start page.