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