Examples of unscaledValue()


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

    int roundingModel = BigDecimal.ROUND_HALF_UP;
    validateDecimalMinMax(destinationDecimal);
    // First limit the number of digits and then the precision.
    // Try and round to 29 digits because we can sometimes do that
    BigInteger allWordBigInt;
    allWordBigInt = destinationDecimal.unscaledValue();
    if (allWordBigInt.bitLength() > 96) {
      destinationDecimal = destinationDecimal.round(new MathContext(29));
      // see if 29 digits uses more than 96 bits
      if (allWordBigInt.bitLength() > 96) {
        // Dang. It was over 97 bits so shorten it one more digit to
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

    // it turns out the max number gets more digits when
    // it's scale is set to 30. so we can't use the max number when there is
    // a scale
    BigDecimal modifiedDecimal = endDecimal;
    System.out.println("integer piece starts                       as "
        + modifiedDecimal.unscaledValue().toString(16) + " scale=: "
        + modifiedDecimal.scale());
    System.out.println("integer piece after rounding without scale is "
        + VariantUtilities.roundToMSDecimal(modifiedDecimal)
            .unscaledValue().toString(16) + " scale=: "
        + modifiedDecimal.scale());
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

    }

    System.out.println("");
    modifiedDecimal = endDecimal.subtract(incrementDecimal);
    System.out.println("integer piece starts                       as "
        + modifiedDecimal.unscaledValue().toString(16) + " scale=: "
        + modifiedDecimal.scale());
    System.out.println("integer piece after rounding without scale is "
        + VariantUtilities.roundToMSDecimal(modifiedDecimal)
            .unscaledValue().toString(16) + " scale=: "
        + modifiedDecimal.scale());
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()

    // (3) m     = s * 10**-m.scale()  from 1
    // (4) n - k = -m.scale()          by 2, 3
    // (5) n     = k - m.scale()
    n = k - m.scale();

    String intRep = s.unscaledValue().toString()// independent of Locale

    if (k <= n && n <= 21) {
      // 6. If k <= n <= 21, return the string consisting of the k digits
      //   of the decimal representation of s (in order, with no leading
      //   zeroes), followed by n-k occurrences of the character '0'.
View Full Code Here

Examples of java.math.BigDecimal.unscaledValue()

        final int scale = cleaned.scale();
        if ( scale > MAX_ALLOWED_PRECISION || scale < -MAX_ALLOWED_PRECISION )
            return new MoneyBigDecimal( cleaned );
        //we may not fit into the Long, but we should try
        //this value may be truncated!
        final BigInteger unscaledBigInt = cleaned.unscaledValue();
        final long unscaledUnits = unscaledBigInt.longValue();
        //check that it was not
        if ( !BigInteger.valueOf(unscaledUnits).equals( unscaledBigInt ) )
            return new MoneyBigDecimal( cleaned );
        //scale could be negative here - we must multiply in that case
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
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.