Class Int64Extensions
Extension methods for
Inheritance
Namespace: X10D.Math
Assembly: X10D.dll
Syntax
public static class Int64Extensions : object
Methods
| Improve this Doc View SourceCountDigits(Int64)
Returns the number of digits in the current 64-bit signed integer.
Declaration
public static int CountDigits(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value whose digit count to compute. |
Returns
Type | Description |
---|---|
System.Int32 | The number of digits in |
DigitalRoot(Int64)
Computes the digital root of this 64-bit integer.
Declaration
public static long DigitalRoot(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value whose digital root to compute. |
Returns
Type | Description |
---|---|
System.Int64 | The digital root of |
Remarks
The digital root is defined as the recursive sum of digits until that result is a single digit.
For example, the digital root of 239 is 5: 2 + 3 + 9 = 14
, then 1 + 4 = 5
.
Factorial(Int64)
Returns the factorial of the current 64-bit signed integer.
Declaration
public static long Factorial(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value whose factorial to compute. |
Returns
Type | Description |
---|---|
System.Int64 | The factorial of |
GreatestCommonFactor(Int64, Int64)
Calculates the greatest common factor between the current 64-bit signed integer, and another 64-bit unsigned integer.
Declaration
public static long GreatestCommonFactor(this long value, long other)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The first value. |
System.Int64 | other | The second value. |
Returns
Type | Description |
---|---|
System.Int64 | The greatest common factor between |
IsEven(Int64)
Returns a value indicating whether the current value is evenly divisible by 2.
Declaration
public static bool IsEven(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value whose parity to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
IsOdd(Int64)
Returns a value indicating whether the current value is not evenly divisible by 2.
Declaration
public static bool IsOdd(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value whose parity to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
IsPrime(Int64)
Returns a value indicating whether the current value is a prime number.
Declaration
public static bool IsPrime(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value whose primality to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
LowestCommonMultiple(Int64, Int64)
Calculates the lowest common multiple between the current 64-bit signed integer, and another 64-bit signed integer.
Declaration
public static long LowestCommonMultiple(this long value, long other)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The first value. |
System.Int64 | other | The second value. |
Returns
Type | Description |
---|---|
System.Int64 | The lowest common multiple between |
Mod(Int64, Int64)
Performs a modulo operation which supports a negative dividend.
Declaration
public static long Mod(this long dividend, long divisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | dividend | The dividend. |
System.Int64 | divisor | The divisor. |
Returns
Type | Description |
---|---|
System.Int64 | 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(Int64)
Returns the multiplicative persistence of a specified value.
Declaration
public static int MultiplicativePersistence(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | 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.
Sign(Int64)
Returns an integer that indicates the sign of this 64-bit signed integer.
Declaration
public static int Sign(this long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | A signed number. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
System.Int32 | A number that indicates the sign of
|
Wrap(Int64, Int64)
Wraps the current 64-bit signed integer between 0 and a high value.
Declaration
public static long Wrap(this long value, long length)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to wrap. |
System.Int64 | length | The exclusive upper bound. |
Returns
Type | Description |
---|---|
System.Int64 | The wrapped value. |
Wrap(Int64, Int64, Int64)
Wraps the current 64-bit signed integer between a low and a high value.
Declaration
public static long Wrap(this long value, long low, long high)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to wrap. |
System.Int64 | low | The inclusive lower bound. |
System.Int64 | high | The exclusive upper bound. |
Returns
Type | Description |
---|---|
System.Int64 | The wrapped value. |