Examples of scaleByPowerOfTen()


Examples of java.math.BigDecimal.scaleByPowerOfTen()

      result = result.multiply(qc, MathContext.DECIMAL32);
      result = result.multiply(qe, MathContext.DECIMAL32);
      result = result.multiply(ql, MathContext.DECIMAL32);
      assert result.compareTo(BigDecimal.ZERO) >= 0 && result.compareTo(BigDecimal.ONE) <= 0;

      long round5 = result.scaleByPowerOfTen(5).longValue();
      result = BigDecimal.valueOf(round5, 5);
      assert result.compareTo(BigDecimal.ZERO) >= 0 && result.compareTo(BigDecimal.ONE) <= 0;

      return result;
   }
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

       
        /*
         * After getting the normalized BigDecimal, we need to scale the value
         * with the exponent.
         */
        return normalizedVal.scaleByPowerOfTen(exponent * sign);
    }
   
    /**
     * Reads a sorted {@code BigDecimal} in normalized format with a single
     * digit to the left of the decimal point.
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

    result = result.multiply(qc, MathContext.DECIMAL32);
    result = result.multiply(qe, MathContext.DECIMAL32);
    result = result.multiply(ql, MathContext.DECIMAL32);
    assert result.compareTo(BigDecimal.ZERO) >= 0 && result.compareTo(BigDecimal.ONE) <= 0;

    long round5 = result.scaleByPowerOfTen(5).longValue();
    result = BigDecimal.valueOf(round5, 5);
    assert result.compareTo(BigDecimal.ZERO) >= 0 && result.compareTo(BigDecimal.ONE) <= 0;

    return result;
  }
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

                String text = getText(0, offset);
                text = text.replace(',', '.');
                BigDecimal dec = new BigDecimal(text);
                if (str.equals("k"))
                {
                    dec = dec.scaleByPowerOfTen(3);
                }
                else if (str.equals("m"))
                {
                    dec = dec.scaleByPowerOfTen(6);
                }
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

                {
                    dec = dec.scaleByPowerOfTen(3);
                }
                else if (str.equals("m"))
                {
                    dec = dec.scaleByPowerOfTen(6);
                }
                else if (str.equals("b"))
                {
                    dec = dec.scaleByPowerOfTen(9);
                }
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

                {
                    dec = dec.scaleByPowerOfTen(6);
                }
                else if (str.equals("b"))
                {
                    dec = dec.scaleByPowerOfTen(9);
                }
                super.remove(0, offset);
                String outcome = dec.toBigIntegerExact().toString();
                outcome = outcome.replace('.', decimalSeparator);
                super.insertString(0, outcome, a);
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

                // rescale if we've lost digits after the decimal point
                if (bd.scale() < scale) {
                    bd = bd.setScale(scale);
                }
                bd = bd.scaleByPowerOfTen(bd.scale());  
                clean = bd.toString();
            }
            // handle negatives
            if(negative) {
                if("-".equals(clean) || "0".equals(clean) || "-0".equals(clean)) {
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

                // rescale if we've lost digits after the decimal point
                if (bd.scale() < scale) {
                    bd = bd.setScale(scale);
                }
                bd = bd.scaleByPowerOfTen(bd.scale());  
                clean = bd.toString();
            }
            // handle negatives
            if(negative) {
                if("-".equals(clean) || "0".equals(clean) || "-0".equals(clean)) {
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

                // rescale if we've lost digits after the decimal point
                if (bd.scale() < scale) {
                    bd = bd.setScale(scale);
                }
                bd = bd.scaleByPowerOfTen(bd.scale());  
                clean = bd.toString();
            }
            // handle negatives
            if(negative) {
                if("-".equals(clean) || "0".equals(clean) || "-0".equals(clean)) {
View Full Code Here

Examples of java.math.BigDecimal.scaleByPowerOfTen()

            val = BigDecimal.valueOf(NumberFormat.getCurrencyFormat(currencyCode).parse(text));
        } catch (IllegalArgumentException badCurrencyCode) {
            throw new CurrencyParseException("Unknown currency "+currencyCode, badCurrencyCode);
        }
        int decimalPlaces = getDecimalPlaces(currencyCode);
        return val.scaleByPowerOfTen(decimalPlaces);
    }

    public Date parseDate(String dateString) throws DateParseException {
      dateString = validateDateString(dateString);
     
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.