本文整理匯總了Java中java.math.MathContext.DECIMAL128屬性的典型用法代碼示例。如果您正苦於以下問題:Java MathContext.DECIMAL128屬性的具體用法?Java MathContext.DECIMAL128怎麽用?Java MathContext.DECIMAL128使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.math.MathContext
的用法示例。
在下文中一共展示了MathContext.DECIMAL128屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertStringTypes
private Object convertStringTypes(Object val, HCatFieldSchema hfs) {
HCatFieldSchema.Type hfsType = hfs.getType();
if (hfsType == HCatFieldSchema.Type.STRING
|| hfsType == HCatFieldSchema.Type.VARCHAR
|| hfsType == HCatFieldSchema.Type.CHAR) {
String str = val.toString();
if (doHiveDelimsReplacement) {
str = FieldFormatter.hiveStringReplaceDelims(str,
hiveDelimsReplacement, hiveDelimiters);
}
if (hfsType == HCatFieldSchema.Type.STRING) {
return str;
} else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
HiveVarchar hvc = new HiveVarchar(str, vti.getLength());
return hvc;
} else if (hfsType == HCatFieldSchema.Type.CHAR) {
CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
HiveChar hc = new HiveChar(val.toString(), cti.getLength());
return hc;
}
} else if (hfsType == HCatFieldSchema.Type.DECIMAL) {
BigDecimal bd = new BigDecimal(val.toString(), MathContext.DECIMAL128);
HiveDecimal hd = HiveDecimal.create(bd);
return hd;
}
return null;
}
示例2: Expression
/**
* Creates a new Expression object and calculates it
*
* @param expression
* expression to calculate
* @throws ExpressionException
* if expression couldn't be parsed
*/
public Expression(String expression) throws ExpressionException {
this.expression = expression;
com.udojava.evalex.Expression exp = new com.udojava.evalex.Expression(
getScientificExpression().replaceAll(" ", "").replaceAll("=", ""), MathContext.DECIMAL128);
this.solution = exp.eval();
}