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
xTThe first value to add.
yTThe second value to add.
Returns
- T
The sum of
xandy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.- OverflowException
The sum of
xandyis less than or greater than the byTvalidMinValueandMaxValue.
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
xTThe first value to AND.
yTThe second value to AND.
Returns
- T
The result of
xANDy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, short, int, long, sbyte, ushort, uint or ulong.
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
xTThe left-hand operand.
yTThe right-hand operand.
Returns
- T
The value of
y.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.
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
xTThe value to calculate with
y.assignmentAssignmentOperatorOne of the enumeration values that specifies the rules to apply for the assignment operator of
xandy.yTThe value to calculate with
x.
Returns
- T
The result of the
assignmentforxandy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.
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
xTThe dividend.
yTThe divisor.
Returns
- T
The result of dividing
xbyy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.- DivideByZeroException
yis zero.- OverflowException
The sum of
xandyis less than or greater than the byTvalidMinValueandMaxValue.
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
xTThe first value to XOR.
yTThe second value to XOR.
Returns
- T
The result of
xXORy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, short, int, long, sbyte, ushort, uint or ulong.
LeftShift<T>(T, T)
Performs an arithmetic left shift (<<) operation.
public static T LeftShift<T>(T x, T y) where T : struct, IConvertible
Parameters
xTThe bit pattern to be shifted.
yTThe number of bits to shift the bit pattern.
Returns
- T
The result of shifting the bit pattern.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, short, int, sbyte, ushort.
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
xTThe multiplicand.
yTThe multiplier.
Returns
- T
The result of multiplying
xandy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.- OverflowException
The sum of
xandyis less than or greater than the byTvalidMinValueandMaxValue.
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
xTThe first value to OR.
yTThe second value to OR.
Returns
- T
The result of
xORy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, short, int, long, sbyte, ushort, uint or ulong.
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
xTThe dividend.
yTThe divisor.
Returns
- T
The remainder after dividing
xbyy.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.- DivideByZeroException
yis zero.- OverflowException
The sum of
xandyis less than or greater than the byTvalidMinValueandMaxValue.
RightShift<T>(T, T)
Performs an arithmetic right shift (>>) operation.
public static T RightShift<T>(T x, T y) where T : struct, IConvertible
Parameters
xTThe bit pattern to be shifted.
yTThe number of bits to shift the bit pattern.
Returns
- T
The result of shifting the bit pattern.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, short, int, sbyte, ushort.
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
xTThe minuend.
yTThe subtrahend.
Returns
- T
The result of subtracting
yfromx.
Type Parameters
TThe type of the values for the operand operation.
Exceptions
- TypeArgumentException
Tis outside the range of allowed types.
Allowed types are: byte, decimal, double, short, int, long, sbyte, float, ushort, uint or ulong.- OverflowException
The sum of
xandyis less than or greater than the byTvalidMinValueandMaxValue.
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
TThe type of the value for an operand operation.