Package java.math

Examples of java.math.BigDecimal.scale()


                throw new InvalidDatatypeValueException(msg);
            }enumCheck(d, enumDecimal);
        }

        if ((fFacetsDefined & DatatypeValidator.FACET_FRACTIONDIGITS)!=0) {
            if (d.scale() > fFractionDigits) {
                String msg = getErrorString(
                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.FRACTION_EXCEEDED],
                                           new Object[] {
                                               "'" + content + "'" + " with fractionDigits = '"+ d.scale() +"'",
                                               "'" + fFractionDigits + "'"
View Full Code Here


        if ((fFacetsDefined & DatatypeValidator.FACET_FRACTIONDIGITS)!=0) {
            if (d.scale() > fFractionDigits) {
                String msg = getErrorString(
                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.FRACTION_EXCEEDED],
                                           new Object[] {
                                               "'" + content + "'" + " with fractionDigits = '"+ d.scale() +"'",
                                               "'" + fFractionDigits + "'"
                                           });
                throw new InvalidDatatypeValueException(msg);
            }
        }
View Full Code Here

                                           });
                throw new InvalidDatatypeValueException(msg);
            }
        }
        if ((fFacetsDefined & DatatypeValidator.FACET_TOTALDIGITS)!=0) {
            int totalDigits = d.movePointRight(d.scale()).toString().length() -
                              ((d.signum() < 0) ? 1 : 0); // account for minus sign
            if (totalDigits > fTotalDigits) {

                String msg = getErrorString(
                                           DatatypeMessageProvider.fgMessageKeys[DatatypeMessageProvider.TOTALDIGITS_EXCEEDED],
View Full Code Here

            28));
      }
    }
    // the bit manipulations above may change the scale so do it afterwards
    // round the scale to the max MS can support
    if (destinationDecimal.scale() > 28) {
      destinationDecimal = destinationDecimal.setScale(28, roundingModel);
    }
    if (destinationDecimal.scale() < 0) {
      destinationDecimal = destinationDecimal.setScale(0, roundingModel);
    }
View Full Code Here

    // the bit manipulations above may change the scale so do it afterwards
    // round the scale to the max MS can support
    if (destinationDecimal.scale() > 28) {
      destinationDecimal = destinationDecimal.setScale(28, roundingModel);
    }
    if (destinationDecimal.scale() < 0) {
      destinationDecimal = destinationDecimal.setScale(0, roundingModel);
    }
    return destinationDecimal;
  }
}
View Full Code Here

            boolean negative = clean.startsWith("-");
            if (rescale && clean.indexOf(DoubleData.getDecimalSeparatorStr()) != -1) {
                BigDecimal bd = new BigDecimal(clean);

                // 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();
            }
View Full Code Here

                // 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

    // 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());
    System.out.println("integer piece after rounding with scale 30 is "
View Full Code Here

        + 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());
    System.out.println("integer piece after rounding with scale 30 is "
        + VariantUtilities.roundToMSDecimal(
            modifiedDecimal.setScale(30)).unscaledValue().toString(
            16) + " scale=: " + modifiedDecimal.scale());
    try {
View Full Code Here

            .unscaledValue().toString(16) + " scale=: "
        + modifiedDecimal.scale());
    System.out.println("integer piece after rounding with scale 30 is "
        + VariantUtilities.roundToMSDecimal(
            modifiedDecimal.setScale(30)).unscaledValue().toString(
            16) + " scale=: " + modifiedDecimal.scale());
    try {
      testVariant.putDecimal(VariantUtilities
          .roundToMSDecimal(modifiedDecimal.setScale(30)));
      fail("should have thrown an exception for a number whose scale "
          + "change created too many digits to be represented.");
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.