Examples of unscaledValue()


Examples of java.math.BigDecimal.unscaledValue()

 
  public static class BigDecimalConverter extends BaseConverter {
    @Override
    public byte[] convertToNoSqlImpl(Object input) {
      BigDecimal value = (BigDecimal) input;
      BigInteger bi = value.unscaledValue();
      Integer scale = value.scale();
      byte[] bibytes = bi.toByteArray();
      byte[] sbytes = intToBytes(scale);
      byte[] bytes = new byte[bi.toByteArray().length+4];
     
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

        }
        BigDecimal bd = value.divide(dec.value, value.scale() + DIVIDE_SCALE_ADD, BigDecimal.ROUND_HALF_DOWN);
        if (bd.signum() == 0) {
            bd = BigDecimal.ZERO;
        } else if (bd.scale() > 0) {
            if (!bd.unscaledValue().testBit(0)) {
                String s = bd.toString();
                int i = s.length() - 1;
                while (i >= 0 && s.charAt(i) == '0') {
                    i--;
                }
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

            // were all introduced in Java 5, and we still need to support
            // older platforms.
            BigDecimal dec = new BigDecimal(Double.toString(d));

            // See how many trailing zeros we have after the decimal point.
            long unscaledValue = dec.unscaledValue().longValue();
            int scale = dec.scale();
            while (scale > 0 && unscaledValue % 10 == 0) {
                scale--;
                unscaledValue /= 10;
            }
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

      if (object == null) {
        output.writeVarInt(NULL, true);
        return;
      }
      BigDecimal value = (BigDecimal)object;
      bigIntegerSerializer.write(kryo, output, value.unscaledValue());
      output.writeInt(value.scale(), false);
    }

    public BigDecimal read (Kryo kryo, Input input, Class<BigDecimal> type) {
      BigInteger unscaledValue = bigIntegerSerializer.read(kryo, input, null);
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

      if (object == null) {
        output.writeByte(NULL);
        return;
      }
      BigDecimal value = (BigDecimal)object;
      bigIntegerSerializer.write(kryo, output, value.unscaledValue());
      output.writeInt(value.scale(), false);
    }

    public BigDecimal read (Kryo kryo, Input input, Class<BigDecimal> type) {
      BigInteger unscaledValue = bigIntegerSerializer.read(kryo, input, null);
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

                MathContext mc = new MathContext(compPrec);
                BigDecimal v
                    = new BigDecimal(value.unscaledValue(), scale, mc);

                BigDecimalLayout bdl
                    = new BigDecimalLayout(v.unscaledValue(), v.scale(),
                                           BigDecimalLayoutForm.SCIENTIFIC);

                char[] mant = bdl.mantissa();

                // Add a decimal point if necessary.  The mantissa may not
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

      if (isNegative) {
        bigDec = bigDec.negate();
      }
      bigDec = bigDec.multiply(BigDecimal.valueOf(multiplier));
      StringBuilder buf = new StringBuilder();
      buf.append(bigDec.unscaledValue().toString());
      format(isNegative, buf, -bigDec.scale());
      return buf.toString();
    } else if (number instanceof BigInteger) {
      BigInteger bigInt = (BigInteger) number;
      boolean isNegative = bigInt.signum() < 0;
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

   */
  public void testConstrBI() {
    String a = "1231212478987482988429808779810457634781384756794987";
    BigInteger bA = new BigInteger(a);
    BigDecimal aNumber = new BigDecimal(bA);
    assertEquals("incorrect value", bA, aNumber.unscaledValue());
    assertEquals("incorrect scale", 0, aNumber.scale());

    try {
      new BigDecimal((BigInteger) null);
      fail("No NullPointerException");
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

    RoundingMode rm = RoundingMode.CEILING;
    MathContext mc = new MathContext(precision, rm);
    String res = "1231212478987482988429808779810457634781384757";
    int resScale = -6;
    BigDecimal result = new BigDecimal(bA, mc);
    assertEquals("incorrect value", res, result.unscaledValue().toString());
    assertEquals("incorrect scale", resScale, result.scale());
  }

  /**
   * new BigDecimal(BigInteger value, int scale, MathContext).
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

    RoundingMode rm = RoundingMode.CEILING;
    MathContext mc = new MathContext(precision, rm);
    String res = "1231212478987482988429808779810457634781384757";
    int resScale = 4;
    BigDecimal result = new BigDecimal(bA, aScale, mc);
    assertEquals("incorrect value", res, result.unscaledValue().toString());
    assertEquals("incorrect scale", resScale, result.scale());
  }

  /**
   * new BigDecimal(BigInteger value, int scale).
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.