Class XBigInteger
Extension methods for BigInteger.
Inheritance
System.Object
XBigInteger
Assembly: Galaxon.Core.dll
Syntax
public static class XBigInteger : object
Methods
DigitSum(BigInteger)
Sum of the digits in a BigInteger.
If present, a negative sign is ignored.
Declaration
public static BigInteger DigitSum(this BigInteger n)
Parameters
| Type |
Name |
Description |
| BigInteger |
n |
|
Returns
| Type |
Description |
| BigInteger |
|
GreatestCommonDivisor(BigInteger, BigInteger)
Determine the greatest common divisor of two integers.
Synonyms: greatest common factor, highest common factor.
Declaration
public static BigInteger GreatestCommonDivisor(BigInteger a, BigInteger b)
Parameters
| Type |
Name |
Description |
| BigInteger |
a |
|
| BigInteger |
b |
|
Returns
| Type |
Description |
| BigInteger |
|
IsPalindromic(BigInteger)
Check if a BigInteger is palindromic.
Declaration
public static bool IsPalindromic(this BigInteger n)
Parameters
| Type |
Name |
Description |
| BigInteger |
n |
|
Returns
| Type |
Description |
| System.Boolean |
|
LeastCommonMultiple(BigInteger, BigInteger)
Find the smallest integer which is a multiple of both arguments.
Synonyms: lowest common multiple, smallest common multiple.
For example, the LCM of 4 and 6 is 12.
When adding fractions, the lowest common denominator is equal to the LCM of the
denominators.
Declaration
public static BigInteger LeastCommonMultiple(BigInteger a, BigInteger b)
Parameters
| Type |
Name |
Description |
| BigInteger |
a |
First integer.
|
| BigInteger |
b |
Second integer.
|
Returns
| Type |
Description |
| BigInteger |
The least common multiple.
|
NumDigits(BigInteger)
Get the number of digits in the BigInteger.
The result will be the same for a positive or negative value.
I tried doing this with double.Log() but because double is imprecise it gives wrong results
for values close to but less than powers of 10.
Declaration
public static int NumDigits(this BigInteger n)
Parameters
| Type |
Name |
Description |
| BigInteger |
n |
|
Returns
| Type |
Description |
| System.Int32 |
|
Reverse(BigInteger)
Reverse a BigInteger.
e.g. 123 becomes 321.
Declaration
public static BigInteger Reverse(this BigInteger n)
Parameters
| Type |
Name |
Description |
| BigInteger |
n |
|
Returns
| Type |
Description |
| BigInteger |
|
Sum(IEnumerable<BigInteger>)
Get the sum of all values in the collection.
Declaration
public static BigInteger Sum(this IEnumerable<BigInteger> nums)
Parameters
| Type |
Name |
Description |
| IEnumerable<BigInteger> |
nums |
|
Returns
| Type |
Description |
| BigInteger |
|
Sum(IEnumerable<BigInteger>, Func<BigInteger, BigInteger>)
Get the sum of all values in the collection, transformed by the supplied function.
Declaration
public static BigInteger Sum(this IEnumerable<BigInteger> source, Func<BigInteger, BigInteger> func)
Parameters
| Type |
Name |
Description |
| IEnumerable<BigInteger> |
source |
|
| Func<BigInteger, BigInteger> |
func |
|
Returns
| Type |
Description |
| BigInteger |
|
ToUnsigned(BigInteger)
Get the unsigned, twos-complement version of the value, containing the fewest number of
bytes.
Declaration
public static BigInteger ToUnsigned(this BigInteger n)
Parameters
| Type |
Name |
Description |
| BigInteger |
n |
|
Returns
| Type |
Description |
| BigInteger |
|