code: private Number sum(Number a, Number b) {
      if (a instanceof Integer) {
        return Integer.valueOf(a.intValue() + b.intValue());
      }
      else if (a instanceof Float) {
        return new Float(a.floatValue() + b.floatValue());
      }
      else if (a instanceof Short) {
        return Short.valueOf((short)(a.shortValue() + b.shortValue()));
      }
      else if (a instanceof Byte) {
        return Byte.valueOf((byte)(a.byteValue() + b.byteValue()));
      }
      else if (a instanceof Long) {
        return Long.valueOf((a.longValue() + b.longValue()));
      }
      else {
        // should never happen
        throw new MetricsException("Invalid number type");
      }
              
    }
docs: Adds two numbers, coercing the second to the type of the first.