Exemplo n.º 1
0
 /* Result is the numeric value of the smallest value.
  */
 public static SchemaTypeNumber min(SchemaTypeNumber value1, SchemaTypeNumber value2) {
   switch (java.lang.Math.max(value1.numericType(), value2.numericType())) {
     case SchemaTypeNumber.NUMERIC_VALUE_INT:
       return new SchemaInt(java.lang.Math.min(value1.intValue(), value2.intValue()));
     case SchemaTypeNumber.NUMERIC_VALUE_LONG:
       return new SchemaLong(java.lang.Math.min(value1.longValue(), value2.longValue()));
     case SchemaTypeNumber.NUMERIC_VALUE_BIGINTEGER:
       return new SchemaInteger(value1.bigIntegerValue().min(value2.bigIntegerValue()));
     case SchemaTypeNumber.NUMERIC_VALUE_FLOAT:
       return new SchemaFloat(java.lang.Math.min(value1.floatValue(), value2.floatValue()));
     case SchemaTypeNumber.NUMERIC_VALUE_DOUBLE:
       return new SchemaDouble(java.lang.Math.min(value1.doubleValue(), value2.doubleValue()));
   }
   return new SchemaDecimal(value1.bigDecimalValue().min(value2.bigDecimalValue()));
 }
Exemplo n.º 2
0
 /* Result is the numeric value of -value.
  */
 public static SchemaTypeNumber unaryMinus(SchemaTypeNumber value) {
   switch (value.numericType()) {
     case SchemaTypeNumber.NUMERIC_VALUE_INT:
       return new SchemaInt(-value.intValue());
     case SchemaTypeNumber.NUMERIC_VALUE_LONG:
       return new SchemaLong(-value.longValue());
     case SchemaTypeNumber.NUMERIC_VALUE_BIGINTEGER:
       return new SchemaInteger(
           value.bigIntegerValue().negate()); // note: possible loss of precision
     case SchemaTypeNumber.NUMERIC_VALUE_FLOAT:
       return new SchemaFloat(-value.floatValue());
     case SchemaTypeNumber.NUMERIC_VALUE_DOUBLE:
       return new SchemaDouble(-value.doubleValue());
   }
   return new SchemaDecimal(value.bigDecimalValue().negate());
 }
Exemplo n.º 3
0
 protected static SchemaTypeNumber getCommonNumberInstance(
     int numericType, SchemaTypeNumber a_value) {
   switch (numericType) {
     case SchemaTypeNumber.NUMERIC_VALUE_INT:
       return new SchemaInt(a_value.intValue());
     case SchemaTypeNumber.NUMERIC_VALUE_LONG:
       return new SchemaLong(a_value.longValue());
     case SchemaTypeNumber.NUMERIC_VALUE_BIGINTEGER:
       return new SchemaInteger(a_value.bigIntegerValue());
     case SchemaTypeNumber.NUMERIC_VALUE_FLOAT:
       return new SchemaFloat(a_value.floatValue());
     case SchemaTypeNumber.NUMERIC_VALUE_DOUBLE:
       return new SchemaDouble(a_value.doubleValue());
     case SchemaTypeNumber.NUMERIC_VALUE_BIGDECIMAL:
       return new SchemaDecimal(a_value.bigDecimalValue());
   }
   return null;
 }