Class BigIntegerExtensions
Math-related extension methods for
Inheritance
Namespace: X10D.Math
Assembly: X10D.dll
Syntax
public static class BigIntegerExtensions : object
Methods
| Improve this Doc View SourceCountDigits(BigInteger)
Returns the number of digits in the current integer.
Declaration
public static int CountDigits(this BigInteger value)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value whose digit count to compute. |
Returns
Type | Description |
---|---|
System.Int32 | The number of digits in |
DigitalRoot(BigInteger)
Computes the digital root of this 8-bit integer.
Declaration
public static int DigitalRoot(this BigInteger value)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value whose digital root to compute. |
Returns
Type | Description |
---|---|
System.Int32 | The digital root of |
Remarks
The digital root is defined as the recursive sum of digits until that result is a single digit.
Factorial(BigInteger)
Returns the factorial of the current 64-bit signed integer.
Declaration
public static BigInteger Factorial(this BigInteger value)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value whose factorial to compute. |
Returns
Type | Description |
---|---|
BigInteger | The factorial of |
GreatestCommonFactor(BigInteger, BigInteger)
Calculates the greatest common factor between this, and another,
Declaration
public static BigInteger GreatestCommonFactor(this BigInteger value, BigInteger other)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The first value. |
BigInteger | other | The second value. |
Returns
Type | Description |
---|---|
BigInteger | The greatest common factor between |
IsOdd(BigInteger)
Returns a value indicating whether the current value is not evenly divisible by 2.
Declaration
public static bool IsOdd(this BigInteger value)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value whose parity to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
IsPrime(BigInteger)
Returns a value indicating whether the current value is a prime number.
Declaration
public static bool IsPrime(this BigInteger value)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value whose primality to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
LowestCommonMultiple(BigInteger, BigInteger)
Calculates the lowest common multiple between the current 64-bit signed integer, and another 64-bit signed integer.
Declaration
public static BigInteger LowestCommonMultiple(this BigInteger value, BigInteger other)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The first value. |
BigInteger | other | The second value. |
Returns
Type | Description |
---|---|
BigInteger | The lowest common multiple between |
Mod(BigInteger, BigInteger)
Performs a modulo operation which supports a negative dividend.
Declaration
public static BigInteger Mod(this BigInteger dividend, BigInteger divisor)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | dividend | The dividend. |
BigInteger | divisor | The divisor. |
Returns
Type | Description |
---|---|
BigInteger | The result of |
Remarks
The %
operator (commonly called the modulo operator) in C# is not defined to be modulo, but is instead
remainder. This quirk inherently makes it difficult to use modulo in a negative context, as x % y
where x is
negative will return a negative value, akin to -(x % y)
, even if precedence is forced. This method provides a
modulo operation which supports negative dividends.
MultiplicativePersistence(BigInteger)
Returns the multiplicative persistence of a specified value.
Declaration
public static int MultiplicativePersistence(this BigInteger value)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value whose multiplicative persistence to calculate. |
Returns
Type | Description |
---|---|
System.Int32 | The multiplicative persistence. |
Remarks
Multiplicative persistence is defined as the recursive digital product until that product is a single digit.
Wrap(BigInteger, BigInteger)
Wraps the current integer between 0 and a high value.
Declaration
public static BigInteger Wrap(this BigInteger value, BigInteger length)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value to wrap. |
BigInteger | length | The exclusive upper bound. |
Returns
Type | Description |
---|---|
BigInteger | The wrapped value. |
Wrap(BigInteger, BigInteger, BigInteger)
Wraps the current integer between a low and a high value.
Declaration
public static BigInteger Wrap(this BigInteger value, BigInteger low, BigInteger high)
Parameters
Type | Name | Description |
---|---|---|
BigInteger | value | The value to wrap. |
BigInteger | low | The inclusive lower bound. |
BigInteger | high | The exclusive upper bound. |
Returns
Type | Description |
---|---|
BigInteger | The wrapped value. |