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