Package java.math

Examples of java.math.BigDecimal.scale()


                case Types.SQL_NUMERIC :
                case Types.SQL_DECIMAL : {
                    BigDecimal dec = (BigDecimal) a;

                    if (scale != dec.scale()) {
                        dec = dec.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
                    }

                    if (JavaSystem.precision(dec) > precision) {
                        throw Error.error(ErrorCode.X_22003);
View Full Code Here


                try {
                    BigDecimal decimal = new BigDecimal(token.tokenString);

                    token.tokenValue = decimal;
                    token.dataType = NumberType.getNumberType(Types.NUMERIC,
                            JavaSystem.precision(decimal), decimal.scale());
                } catch (Exception e2) {
                    token.tokenType   = Tokens.X_MALFORMED_NUMERIC;
                    token.isMalformed = true;

                    return;
View Full Code Here

                case Types.SQL_DECIMAL : {
                    a = convertToDecimal(a);

                    BigDecimal dec = (BigDecimal) a;

                    if (scale != dec.scale()) {
                        dec = dec.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
                    }

                    return dec;
                }
View Full Code Here

                    if (precision - scale > 9 && o instanceof Integer) {
                        return 0;
                    }

                    BigDecimal dec = convertToDecimal(o);
                    int        s   = dec.scale();
                    int        p   = JavaSystem.precision(dec);

                    if (s < 0) {
                        p -= s;
                        s = 0;
View Full Code Here

            return 0;
        }

        BigDecimal value = ((BigDecimal) a);

        if (value.scale() == 0) {
            return 0;
        }

        value = value.setScale(0, BigDecimal.ROUND_FLOOR);
        value = ((BigDecimal) a).subtract(value);
View Full Code Here

        boolean valid = true;

        if (text.length() > 0) {
            try {
                BigDecimal numericAmount = new BigDecimal(text);
                valid = (numericAmount.scale() <= 2 && numericAmount.signum() >= 0);
            } catch (NumberFormatException ex) {
                valid = false;
            }
        }
View Full Code Here

                // get the quantity..
                BigDecimal quantity = item.getBigDecimal("quantity");

                // test quantity if INT pass as is; if not pass as 1
                if (quantity.scale() > 0) {
                    request.put("item_" + lineNumber + "_quantity", "1");
                } else {
                    request.put("", Integer.toString(quantity.intValue()));
                }
View Full Code Here

                    equals.nextToken().trim().equals("q") &&
                    equals.hasMoreTokens()) {
                    String qString = equals.nextToken().trim();
                    try {
                        BigDecimal qFoundValue = new BigDecimal(qString);
                        if (qFoundValue.scale() <= 3) {
                            float qFloat = qFoundValue.floatValue();
                            if (!(qFloat < 0f || qFloat > 1f)) {
                                // Found a valid qvalue, so use it.
                                qValue = qFoundValue;
                            } else {
View Full Code Here

            }
            enumCheck(d, enumDecimal);
        }

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

        if ( (fFacetsDefined & DatatypeValidator.FACET_FRACTIONDIGITS)!=0 ) {
            if ( d.scale() > fFractionDigits )
                throw new InvalidDatatypeValueException(
                                                       getErrorString(DatatypeMessageProvider.FRACTION_EXCEEDED,
                                                                      DatatypeMessageProvider.MSG_NONE,
                                                                      new Object[] { "'" + content + "'" + " with fractionDigits = '"+ d.scale() +"'"
                                                                          , "'" + fFractionDigits + "'"}));
        }
        if ( (fFacetsDefined & DatatypeValidator.FACET_TOTALDIGITS)!=0 ) {
            int totalDigits = d.movePointRight(d.scale()).toString().length() -
                              ((d.signum() < 0) ? 1 : 0); // account for minus sign
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.