Examples of unscaledValue()


Examples of java.math.BigDecimal.unscaledValue()

   
    private static class BigDecimalColumnSerializer extends ColumnSerializer {
        protected void writeObject(ObjectOutput out, Object obj) throws IOException {
            BigDecimal val = (BigDecimal)obj;
            out.writeInt(val.scale());
            BigInteger unscaled = val.unscaledValue();
            byte[] bytes = unscaled.toByteArray();
            out.writeInt(bytes.length);
            out.write(bytes);
        }
        protected Object readObject(ObjectInput in) throws IOException {
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

                writeByte((byte) DECIMAL_0_1);
            } else if (BigDecimal.ONE.equals(x)) {
                writeByte((byte) (DECIMAL_0_1 + 1));
            } else {
                int scale = x.scale();
                BigInteger b = x.unscaledValue();
                int bits = b.bitLength();
                if (bits <= 63) {
                    if (scale == 0) {
                        writeByte((byte) DECIMAL_SMALL_0);
                        writeVarLong(b.longValue());
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

                return 1;
            } else if (BigDecimal.ONE.equals(x)) {
                return 1;
            }
            int scale = x.scale();
            BigInteger b = x.unscaledValue();
            int bits = b.bitLength();
            if (bits <= 63) {
                if (scale == 0) {
                    return 1 + getVarLongLen(b.longValue());
                }
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()

    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()

        {
            BigDecimal bd = (BigDecimal) number;
            if(bd.scale() == 0)
            {
                // BigDecimal -> BigInteger
                number = bd.unscaledValue();
            }
            else
            {
                double d = bd.doubleValue();
                if(d != Double.POSITIVE_INFINITY && d != Double.NEGATIVE_INFINITY)
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

    // it doesn't handle special cases
    private String getSignificantDigits() {
        // TODO: no need to calculate every time.
        BigDecimal val = value.abs().stripTrailingZeros();
        return val.unscaledValue().toString();
    }

    private String getAllDigits() {
        // TODO: no need to calculate every time.
        BigDecimal val = value.abs();
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

    }

    private String getAllDigits() {
        // TODO: no need to calculate every time.
        BigDecimal val = value.abs();
        return val.unscaledValue().toString();
    }   

    // it doesn't handle special cases
    private int getExponent() {
        // TODO: no need to calculate every time.
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()

        scale = precision;
        if (Math.abs(d2) < 1e16) {
            value = Math.round(d);
        } else {
            BigDecimal bd = BigDecimal.valueOf(d).setScale(precision, RoundingMode.HALF_UP);
            value = bd.unscaledValue().longValue();
        }
    }

    private double tens(int scale) {
        return scale < TENS.length ? TENS[scale] : Math.pow(10, 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.