Table of Contents

Class Calculator

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Provides a set of static methods for generic arithmetic assignment operations.

public static class Calculator
Inheritance
Object
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 T

The first value to add.

y T

The second value to add.

Returns

T

The sum of x and 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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

System.OverflowException

The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

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 T

The first value to AND.

y T

The second value to AND.

Returns

T

The result of x AND 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: System.Byte, System.Int16, System.Int32, System.Int64, System.SByte, System.UInt16, System.UInt32 or System.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 T

The left-hand operand.

y T

The 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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.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 T

The value to calculate with y.

assignment AssignmentOperator

One of the enumeration values that specifies the rules to apply for the assignment operator of x and y.

y T

The value to calculate with x.

Returns

T

The result of the assignment for x and 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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.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 T

The dividend.

y T

The divisor.

Returns

T

The result of dividing x by 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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

System.DivideByZeroException

y is zero.

System.OverflowException

The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

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 T

The first value to XOR.

y T

The second value to XOR.

Returns

T

The result of x XOR 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: System.Byte, System.Int16, System.Int32, System.Int64, System.SByte, System.UInt16, System.UInt32 or System.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 T

The bit pattern to be shifted.

y T

The 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: System.Byte, System.Int16, System.Int32, System.SByte, System.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 T

The multiplicand.

y T

The multiplier.

Returns

T

The result of multiplying x and 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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

System.OverflowException

The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

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 T

The first value to OR.

y T

The second value to OR.

Returns

T

The result of x OR 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: System.Byte, System.Int16, System.Int32, System.Int64, System.SByte, System.UInt16, System.UInt32 or System.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 T

The dividend.

y T

The divisor.

Returns

T

The remainder after dividing x by 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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

System.DivideByZeroException

y is zero.

System.OverflowException

The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

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 T

The bit pattern to be shifted.

y T

The 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: System.Byte, System.Int16, System.Int32, System.SByte, System.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 T

The minuend.

y T

The subtrahend.

Returns

T

The result of subtracting y from x.

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: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.

System.OverflowException

The sum of x and y is less than or greater than the by T valid MinValue and MaxValue.

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.

Exceptions

TypeArgumentOutOfRangeException

T is outside the range of allowed types.
Allowed types are: System.Byte, System.Decimal, System.Double, System.Int16, System.Int32, System.Int64, System.SByte, System.Single, System.UInt16, System.UInt32 or System.UInt64.