Class Calculator
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
Provides a set of static methods for generic arithmetic assignment operations.
public static class Calculator
- Inheritance
-
Calculator
Methods
Add<T>(T, T)
Performs a binary addition of the two specified values.
public static T Add<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first value to add.
y
TThe second value to add.
Returns
- T
The sum of
x
andy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.- OverflowException
The sum of
x
andy
is less than or greater than the byT
validMinValue
andMaxValue
.
And<T>(T, T)
Performs a a bitwise logical conjunction (AND) operation of the two specified values.
public static T And<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first value to AND.
y
TThe second value to AND.
Returns
- T
The result of
x
ANDy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, Int64, SByte, UInt16, UInt32 or UInt64.
Assign<T>(T, T)
Performs an assignment of the right-hand operand to the left-hand operand.
public static T Assign<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe left-hand operand.
y
TThe right-hand operand.
Returns
- T
The value of
y
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.
Calculate<T>(T, AssignmentOperator, T)
Performs a calculation following the assignment
of the two specified values.
public static T Calculate<T>(T x, AssignmentOperator assignment, T y)
where T : struct, IConvertible
Parameters
x
TThe value to calculate with
y
.assignment
AssignmentOperatorOne of the enumeration values that specifies the rules to apply for the assignment operator of
x
andy
.y
TThe value to calculate with
x
.
Returns
- T
The result of the
assignment
forx
andy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.
Divide<T>(T, T)
Performs a binary division of the two specified values.
public static T Divide<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe dividend.
y
TThe divisor.
Returns
- T
The result of dividing
x
byy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.- DivideByZeroException
y
is zero.- OverflowException
The sum of
x
andy
is less than or greater than the byT
validMinValue
andMaxValue
.
ExclusiveOr<T>(T, T)
Performs a bitwise exclusive or (XOR) operation of the two specified values.
public static T ExclusiveOr<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first value to XOR.
y
TThe second value to XOR.
Returns
- T
The result of
x
XORy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, Int64, SByte, UInt16, UInt32 or UInt64.
LeftShift<T>(T, T)
Performs an arithmetic left shift (<<) operation.
public static T LeftShift<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe bit pattern to be shifted.
y
TThe number of bits to shift the bit pattern.
Returns
- T
The result of shifting the bit pattern.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, SByte, UInt16.
Multiply<T>(T, T)
Performs a binary multiplication of the two specified values.
public static T Multiply<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe multiplicand.
y
TThe multiplier.
Returns
- T
The result of multiplying
x
andy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.- OverflowException
The sum of
x
andy
is less than or greater than the byT
validMinValue
andMaxValue
.
Or<T>(T, T)
Performs a bitwise logical disjunction (OR) operation of the two specified values.
public static T Or<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first value to OR.
y
TThe second value to OR.
Returns
- T
The result of
x
ORy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, Int64, SByte, UInt16, UInt32 or UInt64.
Remainder<T>(T, T)
Performs a binary division of the two specified values and computes the remainder hereof.
public static T Remainder<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe dividend.
y
TThe divisor.
Returns
- T
The remainder after dividing
x
byy
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.- DivideByZeroException
y
is zero.- OverflowException
The sum of
x
andy
is less than or greater than the byT
validMinValue
andMaxValue
.
RightShift<T>(T, T)
Performs an arithmetic right shift (>>) operation.
public static T RightShift<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe bit pattern to be shifted.
y
TThe number of bits to shift the bit pattern.
Returns
- T
The result of shifting the bit pattern.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, SByte, UInt16.
Subtract<T>(T, T)
Performs a binary subtraction of the two specified values.
public static T Subtract<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe minuend.
y
TThe subtrahend.
Returns
- T
The result of subtracting
y
fromx
.
Type Parameters
T
The type of the values for the operand operation.
Exceptions
- TypeArgumentException
T
is outside the range of allowed types.
Allowed types are: Byte, Decimal, Double, Int16, Int32, Int64, SByte, Single, UInt16, UInt32 or UInt64.- OverflowException
The sum of
x
andy
is less than or greater than the byT
validMinValue
andMaxValue
.
ValidAsNumericOperand<T>()
Validates if the specified T
is within the allowed range of numeric operands.
public static void ValidAsNumericOperand<T>()
where T : struct, IComparable<T>, IEquatable<T>, IConvertible
Type Parameters
T
The type of the value for an operand operation.