Arithmetic
This static class collects and maintains all arithmetic operators.
Methods
Add
#AddRepository
#Copy all functionality from an ArithmeticRepository into the global server.
Parameters:
| type (Type) | Type pointing at a ArithmeticRepository. |
Returns: True if repo was added.
Apply
#Attempt to run a known operator on two values. This method is the recommended one for arithmetic operations, as it will first attempt the operation on type defined operator overloads.
Parameters:
| fn (Arithmetic.Binary) | |
| a (dynamic) | |
| b (dynamic) |
Returns: Result of Function(a), or an Exception if the function is undefined. Note that this method will return rather than throw that exception, allowing the caller to differenciate between exceptions arising from unrecognised operations and those from the operation implementations.
Apply
#Attempt to run a known operator on two values. Note that null values will act as identities. If you wish to have coalescing nulls you must check for that yourself. Also, in case it wasn't horribly obvious, this is MUCH slower than just calling the appropriate operator on values directly. Only use this method if you have no way of knowing at compile time what types your arguments are.
Parameters:
| op (Arithmetic.Operation) | |
| a (dynamic) | |
| b (dynamic) |
Apply
#Attempt to run a known operator on two values. This method is the recommended one for arithmetic operations, as it will first attempt the operation on type defined operator overloads.
Parameters:
| fn (Arithmetic.Ternary) | |
| a (dynamic) | |
| b (dynamic) | |
| c (dynamic) |
Returns: Result of Function(a, b), or an Exception if the function is undefined. Note that this method will return rather than throw that exception, allowing the caller to differenciate between exceptions arising from unrecognised operations and those from the operation implementations.
Apply
#Try and apply the given function to an argument.
Parameters:
| fn (Arithmetic.Unary) | Function to apply. |
| a (dynamic) | Argument to operate on. |
Returns: Result of Function(a), or an Exception if the function is undefined. Note that this method will return rather than throw that exception, allowing the caller to differenciate between exceptions arising from unrecognised operations and those from the operation implementations.
ApplyBulk
#Apply a binary function to two trees.
Parameters:
| fn (Arithmetic.Binary) | Function to apply. |
| a (ITree) | First tree. |
| b (ITree) | Second tree. |
| token (CancellationToken) | Cancellation token. |
Returns: Resulting values.
ApplyBulk
#Apply an operation to two trees.
Parameters:
| op (Arithmetic.Operation) | Operation to apply. |
| a (ITree) | First tree. |
| b (ITree) | Second tree. |
| token (CancellationToken) | Cancellation token. |
Returns: Resulting values.
ApplyBulk
#Apply a ternary function to three trees.
Parameters:
| fn (Arithmetic.Ternary) | Function to apply. |
| a (ITree) | First tree. |
| b (ITree) | Second tree. |
| c (ITree) | Third tree. |
| token (CancellationToken) | Cancellation token. |
Returns: Resulting values.
ApplyBulk
#Apply a uniary function to a tree.
Parameters:
| fn (Arithmetic.Unary) | Function to apply. |
| a (ITree) | Tree. |
| token (CancellationToken) | Cancellation token. |
Returns: Resulting values.
Div
#Div
#Div
#Div
#Div
#Division
#Division
#Format
#Gets the notational format for the given binary function. The format will include '{0}' and '{1}' fields for the arguments.
Parameters:
| fn (Arithmetic.Binary) |
Format
#Gets the notational format for the given arithmetic operator. The format will include '{0}' and '{1}' fields for the operands.
Parameters:
| op (Arithmetic.Operation) |
Format
#Gets the notational format for the given ternary function. The format will include '{0}', '{1}' and '{2}' fields for the arguments.
Parameters:
| fn (Arithmetic.Ternary) |
Format
#Gets the notational format for the given unary function. The format will include a '{0}' fields for the argument.
Parameters:
| fn (Arithmetic.Unary) |
Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Log
#Max
#Max
#Max
#Max
#Max
#Max
#Max
#Max
#Max
#Max
#Max
#Max
#Min
#Min
#Min
#Min
#Min
#Min
#Min
#Min
#Min
#Min
#Min
#Min
#Mul
#Mul
#Mul
#Mul
#Mul
#MulFloatInteger
#A multiplication method for double and BigIntegers, which operates entirely within the BigInteger range.
Parameters:
| d (double) | Floating point factor. |
| b (BigInteger) | BigInteger base. |
Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiple
#Multiplication
#Multiplication
#Multiplication
#Multiplication
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Pow
#Round
#Round
#Round
#Round
#Round
#Round
#Round
#Round
#Round
#Round
#SmartIntegerDivision
#Perform clever integer division which always reverts to the most appropriate output type.
Parameters:
| numerator (object) | Numerator of either int or BigInteger. |
| denominator (object) | Denominator of either int or BigInteger. |
| result (out object) | Either a double, int or BigInteger depending on the input values. |
Returns: True if an integer division was performed.
SmartIntegerDivision
#Perform clever integer division which always reverts to the most appropriate output type.
Parameters:
| numerator (object) | Numerator of either int or BigInteger. |
| denominator (object) | Denominator of either int or BigInteger. |
Returns: Result of smart integer division or floating point division.