code: public static Number math(int op, Number left, Number right) {
          int type = getCompatibleType(left, right);
          if (type == TYPE_DOUBLE) { 
              return math(op, left.doubleValue(), right.doubleValue()); 
          }
          else if (type == TYPE_FLOAT) { 
              return math(op, left.floatValue(), right.floatValue());
          }
          else if (type == TYPE_LONG) { 
              return math(op, left.longValue(), right.longValue()); 
          }
          else if (type == TYPE_INT) { 
              return math(op, left.intValue(), right.intValue()); 
          }
          else {
              throw new IllegalStateException("unsupported number type: " + type);
          }
      }
docs: Perform a mathematical operation against two numbers. This first
  coerces the two numbers to the best matching type, then performs the
  given operation, and returns a similar type.  For example, adding a
  {@link Long} and an {@link Integer} results in a {@link Long} being
  returned.  In all cases, one of the built-in primitive wrappers will
  be returned (ie: {@link Double}, {@link Float}, {@link Long}, or
  {@link Integer}).  The following operations are supported:
  
  <dl>
  <dt>{@link #OP_ADD}</dt>
  <dd>Add both numbers</dd>
  
  <dt>{@link #OP_SUB}</dt>
  <dd>Substract both numbers</dd>
  
  <dt>{@link #OP_MULT}</dt>
  <dd>Multiply both numbers</dd>
  
  <dt>{@link #OP_DIV}</dt>
  <dd>Divide both numbers</dd>
  
  <dt>{@link #OP_MOD}</dt>
  <dd>Perform a modulus operation on both numbers</dd>
  </dl>
  
  @param op The operation to perform
  @param left The left value to operate on
  @param right The right value to operate on
  
  @return The result of the operation in the suitable type