@Test public void testBigDecimal() { Decimal decimal = new Decimal("decimal(10,1)"); double v = decimal.toBigDecimal("10.555").doubleValue(); assertEquals(10.5, v, 0.0000001); }
public BigDecimal toBigDecimal(String v) { int pointIndex = v.indexOf('.'); int fractionLen = 0; if (pointIndex != -1) { fractionLen = v.length() - pointIndex - 1; } else { v += "."; } if (fractionLen >= mScale) { v = v.substring(0, v.length() - (fractionLen - mScale)); } else { v = StringUtils.rightPad(v, v.length() + (mScale - fractionLen), '0'); } return new BigDecimal(v); }
Decimal { public BigDecimal toBigDecimal(String v) { int pointIndex = v.indexOf('.'); int fractionLen = 0; if (pointIndex != -1) { fractionLen = v.length() - pointIndex - 1; } else { v += "."; } if (fractionLen >= mScale) { v = v.substring(0, v.length() - (fractionLen - mScale)); } else { v = StringUtils.rightPad(v, v.length() + (mScale - fractionLen), '0'); } return new BigDecimal(v); } }
Decimal { public BigDecimal toBigDecimal(String v) { int pointIndex = v.indexOf('.'); int fractionLen = 0; if (pointIndex != -1) { fractionLen = v.length() - pointIndex - 1; } else { v += "."; } if (fractionLen >= mScale) { v = v.substring(0, v.length() - (fractionLen - mScale)); } else { v = StringUtils.rightPad(v, v.length() + (mScale - fractionLen), '0'); } return new BigDecimal(v); } Decimal(String type); }
Decimal { public BigDecimal toBigDecimal(String v) { int pointIndex = v.indexOf('.'); int fractionLen = 0; if (pointIndex != -1) { fractionLen = v.length() - pointIndex - 1; } else { v += "."; } if (fractionLen >= mScale) { v = v.substring(0, v.length() - (fractionLen - mScale)); } else { v = StringUtils.rightPad(v, v.length() + (mScale - fractionLen), '0'); } return new BigDecimal(v); } Decimal(String type); int getPrecision(); int getScale(); static Pair<Integer, Integer> getPrecisionAndScale(String type); BigDecimal toBigDecimal(String v); byte[] toParquetBytes(String v); }
Decimal { public BigDecimal toBigDecimal(String v) { int pointIndex = v.indexOf('.'); int fractionLen = 0; if (pointIndex != -1) { fractionLen = v.length() - pointIndex - 1; } else { v += "."; } if (fractionLen >= mScale) { v = v.substring(0, v.length() - (fractionLen - mScale)); } else { v = StringUtils.rightPad(v, v.length() + (mScale - fractionLen), '0'); } return new BigDecimal(v); } Decimal(String type); int getPrecision(); int getScale(); static Pair<Integer, Integer> getPrecisionAndScale(String type); BigDecimal toBigDecimal(String v); byte[] toParquetBytes(String v);  }