示例#1
0
 /**
  * Apply this operator (function) to the supplied argument
  *
  * @param value the argument
  * @return the result
  */
 protected double applyFunction(double value) {
   switch (m_operator) {
     case 'l':
       return Math.log(value);
     case 'b':
       return Math.abs(value);
     case 'c':
       return Math.cos(value);
     case 'e':
       return Math.exp(value);
     case 's':
       return Math.sqrt(value);
     case 'f':
       return Math.floor(value);
     case 'h':
       return Math.ceil(value);
     case 'r':
       return Math.rint(value);
     case 't':
       return Math.tan(value);
     case 'n':
       return Math.sin(value);
   }
   return Double.NaN;
 }
示例#2
0
 /**
  * Apply this operator to the supplied arguments
  *
  * @param first the first argument
  * @param second the second argument
  * @return the result
  */
 protected double applyOperator(double first, double second) {
   switch (m_operator) {
     case '+':
       return (first + second);
     case '-':
       return (first - second);
     case '*':
       return (first * second);
     case '/':
       return (first / second);
     case '^':
       return Math.pow(first, second);
   }
   return Double.NaN;
 }