Class Operators


  • public final class Operators
    extends java.lang.Object
    This class implements all of the built-in operators both arithmetic and boolean.

    Boolean values will be treated as follows:

    1. if the absolute value is less than 1e-12 it will be considered false. About this... I know is not the ideal approach, but we have a LOT of arithmetic "hacks" all around some projects and this behavior is actually expected.
    2. if the absolute value is bigger or equal than 1e-12 it will be considered true
    3. the boolean results will always be 1.0 for true and 0.0 for false
    4. boolean operations will always have lower precedence than arithmetic operations (i.e. they will be evaluated last)
    5. The precedence (order) of the boolean operators will always be ¬ & | (in accordance to the analogy with arithmetic operators), so that:
                   a & b| b & ¬c -> ((a & b) | (b & (¬c)))
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Operator getBuiltinOperator​(char symbol, int numArguments)
      Retrieves a Built-in operator.
      static Operator[] getOperators()
      Array with all the available operators
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getBuiltinOperator

        public static Operator getBuiltinOperator​(char symbol,
                                                  int numArguments)
        Retrieves a Built-in operator.
        Parameters:
        symbol - Symbol representing the operator
        numArguments - Number of arguments of the operator
        Returns:
        An operator matching the criteria if one exists or null otherwise
        See Also:
        Operator