Show / Hide Table of Contents

Class Calculator

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

Inheritance
Object
Calculator
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class Calculator

Methods

| Improve this Doc View Source

Add<T>(T, T)

Performs a binary addition of the two specified values.

Declaration
public static T Add<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The first value to add.

T y

The second value to add.

Returns
Type Description
T

The sum of x and y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
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 and y is less than or greater than the by T valid MinValue and MaxValue.

| Improve this Doc View Source

And<T>(T, T)

Performs a a bitwise logical conjunction (AND) operation of the two specified values.

Declaration
public static T And<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The first value to AND.

T y

The second value to AND.

Returns
Type Description
T

The result of x AND y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

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

| Improve this Doc View Source

Assign<T>(T, T)

Performs an assignment of the right-hand operand to the left-hand operand.

Declaration
public static T Assign<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The left-hand operand.

T y

The right-hand operand.

Returns
Type Description
T

The value of y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

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

| Improve this Doc View Source

Calculate<T>(T, AssignmentOperator, T)

Performs a calculation following the assignment of the two specified values.

Declaration
public static T Calculate<T>(T x, AssignmentOperator assignment, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The value to calculate with y.

AssignmentOperator assignment

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

T y

The value to calculate with x.

Returns
Type Description
T

The result of the assignment for x and y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

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

| Improve this Doc View Source

Divide<T>(T, T)

Performs a binary division of the two specified values.

Declaration
public static T Divide<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The dividend.

T y

The divisor.

Returns
Type Description
T

The result of dividing x by y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
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 and y is less than or greater than the by T valid MinValue and MaxValue.

| Improve this Doc View Source

ExclusiveOr<T>(T, T)

Performs a bitwise exclusive or (XOR) operation of the two specified values.

Declaration
public static T ExclusiveOr<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The first value to XOR.

T y

The second value to XOR.

Returns
Type Description
T

The result of x XOR y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

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

| Improve this Doc View Source

LeftShift<T>(T, T)

Performs an arithmetic left shift (<<) operation.

Declaration
public static T LeftShift<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The bit pattern to be shifted.

T y

The number of bits to shift the bit pattern.

Returns
Type Description
T

The result of shifting the bit pattern.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

T is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, SByte, UInt16.

| Improve this Doc View Source

Multiply<T>(T, T)

Performs a binary multiplication of the two specified values.

Declaration
public static T Multiply<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The multiplicand.

T y

The multiplier.

Returns
Type Description
T

The result of multiplying x and y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
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 and y is less than or greater than the by T valid MinValue and MaxValue.

| Improve this Doc View Source

Or<T>(T, T)

Performs a bitwise logical disjunction (OR) operation of the two specified values.

Declaration
public static T Or<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The first value to OR.

T y

The second value to OR.

Returns
Type Description
T

The result of x OR y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

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

| Improve this Doc View Source

Remainder<T>(T, T)

Performs a binary division of the two specified values and computes the remainder hereof.

Declaration
public static T Remainder<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The dividend.

T y

The divisor.

Returns
Type Description
T

The remainder after dividing x by y.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
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 and y is less than or greater than the by T valid MinValue and MaxValue.

| Improve this Doc View Source

RightShift<T>(T, T)

Performs an arithmetic right shift (>>) operation.

Declaration
public static T RightShift<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The bit pattern to be shifted.

T y

The number of bits to shift the bit pattern.

Returns
Type Description
T

The result of shifting the bit pattern.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
TypeArgumentException

T is outside the range of allowed types.
Allowed types are: Byte, Int16, Int32, SByte, UInt16.

| Improve this Doc View Source

Subtract<T>(T, T)

Performs a binary subtraction of the two specified values.

Declaration
public static T Subtract<T>(T x, T y)

    where T : struct, IConvertible
Parameters
Type Name Description
T x

The minuend.

T y

The subtrahend.

Returns
Type Description
T

The result of subtracting y from x.

Type Parameters
Name Description
T

The type of the values for the operand operation.

Exceptions
Type Condition
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 and y is less than or greater than the by T valid MinValue and MaxValue.

| Improve this Doc View Source

ValidAsNumericOperand<T>()

Validates if the specified T is within the allowed range of numeric operands.

Declaration
public static void ValidAsNumericOperand<T>()

    where T : struct, IComparable<T>, IEquatable<T>, IConvertible
Type Parameters
Name Description
T

The type of the value for an operand operation.

Exceptions
Type Condition
TypeArgumentOutOfRangeException

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

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright 2008-2022 Geekle. All rights reserved. Code with passion and love; deploy with confidence. 👨‍💻️🔥❤️🚀😎
Generated by DocFX