Class MoreMath
This static class exposes methods that perform a variety of infrequently used, but technically obscure or deceptively tricky mathematical computations.
Inheritance
Namespace: WizardWrx
Assembly: WizardWrx.MoreMath.dll
Syntax
public static class MoreMath : object
Fields
| Improve this Doc View SourceEXCEPTION_ON_INVALID_INPUT
Use with IsGregorianLeapYear and IsValidGregorianYear to cause them to throw an exception when either is fed an invalid Gregorian year, rather than return FALSE.
Declaration
public const bool EXCEPTION_ON_INVALID_INPUT = null
Field Value
Type | Description |
---|---|
System.Boolean |
FALSE_ON_INVALID_INPUT
Use with IsGregorianLeapYear and IsValidGregorianYear to cause them to suppress the ArgumentOutOfRange exception when either is fed an invalid Gregorian year; instead, both return FALSE.
Declaration
public const bool FALSE_ON_INVALID_INPUT = null
Field Value
Type | Description |
---|---|
System.Boolean |
GRGORIAN_CALENDAR_ADOPTION_YEAR
Year values must be greater than this value. Callers may use this constant to perform their own validations, or for other purposes.
The Gregorian calendar was adopted in 1582. To be on the safe side, this class rejects years prior to the following year, since, in its present form, it cannot correctly process dates on the Julian calendar that was in use before 1583.
Declaration
public const int GRGORIAN_CALENDAR_ADOPTION_YEAR = null
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceDecimalShiftLeft(Int32, Int32)
Shift the decimal point of an integer value left by a poisitive number of digits.
Declaration
public static int DecimalShiftLeft(int ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits | Specify the number of digits to the left by which to shift the
value specified by |
Returns
Type | Description |
---|---|
System.Int32 | Return the value of |
DecimalShiftLeft(Int64, Int32)
Shift the decimal point of an integer value left by a poisitive number of digits.
Declaration
public static long DecimalShiftLeft(long ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits | Specify the number of digits to the left by which to shift the
value specified by |
Returns
Type | Description |
---|---|
System.Int64 | Return the value of |
DecimalShiftLeft(UInt32, Int32)
Shift the decimal point of an integer value left by a poisitive number of digits.
Declaration
public static uint DecimalShiftLeft(uint ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits | Specify the number of digits to the left by which to shift the
value specified by |
Returns
Type | Description |
---|---|
System.UInt32 | Return the value of |
DecimalShiftLeft(UInt64, Int32)
Shift the decimal point of an integer value left by a poisitive number of digits.
Declaration
public static ulong DecimalShiftLeft(ulong ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits | Specify the number of digits to the left by which to shift the
value specified by |
Returns
Type | Description |
---|---|
System.UInt64 | Return the value of |
DecimalShiftRight(Decimal, Int32)
Shift the decimal point of a decimal value right by a poisitive number of digits.
Declaration
public static decimal DecimalShiftRight(decimal ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits |
Returns
Type | Description |
---|---|
System.Decimal | Return the value of |
DecimalShiftRight(Double, Int32)
Shift the decimal point of a double value right by a poisitive number of digits.
Declaration
public static double DecimalShiftRight(double ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.Double | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits |
Returns
Type | Description |
---|---|
System.Double | Return the value of |
DecimalShiftRight(Int32, Int32)
Shift the decimal point of an integer value right by a poisitive number of digits.
Declaration
public static int DecimalShiftRight(int ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits |
Returns
Type | Description |
---|---|
System.Int32 | Return the value of |
DecimalShiftRight(Single, Int32)
Shift the decimal point of a float value right by a poisitive number of digits.
Declaration
public static float DecimalShiftRight(float ShiftThis, int NDigits)
Parameters
Type | Name | Description |
---|---|---|
System.Single | ShiftThis | Specify the integer value to be shifted left by the number of digits
specified by |
System.Int32 | NDigits |
Returns
Type | Description |
---|---|
System.Single | Return the value of |
IncrementAndReturnNewValue(ref Int32)
Increment a static (shared in Visual Basic) value, returning the incremented value.
Declaration
public static int IncrementAndReturnNewValue(ref int IncrementThisValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | IncrementThisValue | Pass in a reference to the shared value to increment and return. Since the value is incremented, it must be passed explicitly by reference. |
Returns
Type | Description |
---|---|
System.Int32 | The return value is the initial value of
|
IncrementAndReturnNewValue(ref Int64)
Increment a static (shared in Visual Basic) value, returning the incremented value.
Declaration
public static long IncrementAndReturnNewValue(ref long IncrementThisValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | IncrementThisValue | Pass in a reference to the shared value to increment and return. Since the value is incremented, it must be passed explicitly by reference. |
Returns
Type | Description |
---|---|
System.Int64 | The return value is the initial value of
|
IncrementAndReturnNewValue(ref UInt32)
Increment a static (shared in Visual Basic) value, returning the incremented value.
Declaration
public static uint IncrementAndReturnNewValue(ref uint IncrementThisValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | IncrementThisValue | Pass in a reference to the shared value to increment and return. Since the value is incremented, it must be passed explicitly by reference. |
Returns
Type | Description |
---|---|
System.UInt32 | The return value is the initial value of
|
IncrementAndReturnNewValue(ref UInt64)
Increment a static (shared in Visual Basic) value, returning the incremented value.
Declaration
public static ulong IncrementAndReturnNewValue(ref ulong IncrementThisValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | IncrementThisValue | Pass in a reference to the shared value to increment and return. Since the value is incremented, it must be passed explicitly by reference. |
Returns
Type | Description |
---|---|
System.UInt64 | The return value is the initial value of
|
IsEvenlyDivisibleByAnyInteger(Int32, Int32)
Evaluate whether integer pintDividend
is evenly
divisible by integer pintDivisor
.
Declaration
public static bool IsEvenlyDivisibleByAnyInteger(int pintDividend, int pintDivisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintDividend | Specify the integer to evaluate for even divisibility against
|
System.Int32 | pintDivisor | Specify the integer to determine whether integer
|
Returns
Type | Description |
---|---|
System.Boolean | Return TRUE if integer Otherwise, return FALSE. |
See Also
| Improve this Doc View SourceIsEvenlyDivisibleByAnyInteger(Int64, Int64)
Evaluate whether long integer plngDividend
is
evenly divisible by long integer plngDivisor
.
Declaration
public static bool IsEvenlyDivisibleByAnyInteger(long plngDividend, long plngDivisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | plngDividend | Specify the long integer to evaluate for even divisibility against
|
System.Int64 | plngDivisor | Specify the long integer to determine whether long integer
|
Returns
Type | Description |
---|---|
System.Boolean | Return TRUE if long integer |
See Also
| Improve this Doc View SourceIsGregorianLeapYear(Int32, Boolean)
Given a valid year, return True if the year is a leap year, else return False.
If the input year is invalid, an ArgumentOutOfRange exception is thrown.
According to the first reference cited below, the Grgorian calendar was adopted in 1582. Hence, this formula is invalid for years before 1583. Consequently, any year before 1583 is treated as invalid, and an ArgumentOutOfRange exception is thrown, which is enforced by the IsValidGregorianYear method.
Declaration
public static bool IsGregorianLeapYear(int pintYear, bool pfThrowError = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintYear | Gregorian year number, greater than 1582, to evaluate |
System.Boolean | pfThrowError | Specify FALSE_ON_INVALID_INPUT to suppress the default behavior,
which is for IsValidGregorianYear, when called upon to validate
|
Returns
Type | Description |
---|---|
System.Boolean | TRUE if |
IsValidGregorianYear(Int32, Boolean)
This method returns True if the year is valid for the Gregorian calendar.
The lower limit is exposed as a public constant, GRGORIAN_CALENDAR_ADOPTION_YEAR.
Declaration
public static bool IsValidGregorianYear(int pintYear, bool pfThrowError)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintYear | Gregorian year number, greater than 1582, to evaluate |
System.Boolean | pfThrowError | TRUE if caller wants an invalid input to provoke an exception. To inprove the quality of your internal documentation, You may use public constant EXCEPTION_ON_INVALID_INPUT in lieu of TRUE, and RETURN_ON_INVALID_INPUT in lieu of FALSE. |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the input is a valid Gregorian year. |
Mod(Int32, Int32)
Return the modulus, which is the remainder from dividing one integer by another.
Declaration
public static int Mod(int pintDividend, int pintDivisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintDividend | Specify the number into which |
System.Int32 | pintDivisor | Specify the number by which |
Returns
Type | Description |
---|---|
System.Int32 | The return value is the integer result of dividing
|
Remarks
The Mod and Remainder methods are synonymns. Their simplicity lends them to inline implementation.
See Also
| Improve this Doc View SourceMod(Int64, Int64)
Return the modulus, which is the remainder from dividing one integer by another.
Declaration
public static long Mod(long plngDividend, long plngDivisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | plngDividend | Specify the number into which |
System.Int64 | plngDivisor | Specify the number by which |
Returns
Type | Description |
---|---|
System.Int64 | The return value is the long integer result of dividing
|
Remarks
The Mod and Remainder methods are synonymns. Their simplicity lends them to inline implementation.
See Also
| Improve this Doc View SourceRemainder(Int32, Int32)
Return the modulus, which is the remainder from dividing one integer by another.
Declaration
public static int Remainder(int pintDividend, int pintDivisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pintDividend | Specify the number into which |
System.Int32 | pintDivisor | Specify the number by which |
Returns
Type | Description |
---|---|
System.Int32 | The return value is the integer result of dividing
|
Remarks
The Mod and Remainder methods are synonymns. Their simplicity lends them to inline implementation.
See Also
| Improve this Doc View SourceRemainder(Int64, Int64)
Return the modulus, which is the remainder from dividing one integer by another.
Declaration
public static long Remainder(long plngDividend, long plngDivisor)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | plngDividend | Specify the number into which |
System.Int64 | plngDivisor | Specify the number by which |
Returns
Type | Description |
---|---|
System.Int64 | The return value is the integer result of dividing
|
Remarks
The Mod and Remainder methods are synonymns. Their simplicity lends them to inline implementation.