Package java.math

Examples of java.math.BigDecimal.scale()



      // Some DBs give a negative number when they do not have a value for
      // the scale.  Assume that if the _scale is 0 or positive that the DB really
      // means for that to be the scale, but if it is negative then we do not check.
      if (_scale >= 0 && obj.scale() > _scale)
      {
        Object[] args = new Object[]{
                        Integer.valueOf(obj.scale()),
                        Integer.valueOf(_scale)
                };
View Full Code Here


      // the scale.  Assume that if the _scale is 0 or positive that the DB really
      // means for that to be the scale, but if it is negative then we do not check.
      if (_scale >= 0 && obj.scale() > _scale)
      {
        Object[] args = new Object[]{
                        Integer.valueOf(obj.scale()),
                        Integer.valueOf(_scale)
                };
        // i18n[dataTypeBigDecimal.scaleEceeded=Scale Exceeded: Number
                //of digits to right of decimal place ({0})\nis greater than
                //allowed in column ({1}).]
View Full Code Here

        if (o instanceof BigDecimal) {
            bd = (BigDecimal)o;
        } else {
            bd = new BigDecimal(o.toString());
        }
        if (bd.scale() != scale) {
            bd = bd.setScale(scale);
        }
        return bd;
    }
View Full Code Here

        if (o instanceof BigDecimal) {
            bd = (BigDecimal)o;
        } else {
            bd = new BigDecimal(o.toString());
        }
        if (bd.scale() != scale) {
           bd = bd.setScale(scale);
        }
        return bd;
    }
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_NUMERIC :
            case Types.SQL_DECIMAL : {
                BigDecimal dec = (BigDecimal) a;

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

                int p = JavaSystem.precision(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

    public static Number optimizeNumberRepresentation(Number number)
    {
        if(number instanceof BigDecimal)
        {
            BigDecimal bd = (BigDecimal) number;
            if(bd.scale() == 0)
            {
                // BigDecimal -> BigInteger
                number = bd.unscaledValue();
            }
            else
View Full Code Here

             Object value, boolean isSelected, boolean hasFocus,
             int row, int column) {
          BigDecimal valueAddedTaxPercentage = ((HomePieceOfFurniture)value).getValueAddedTaxPercentage();
          if (valueAddedTaxPercentage != null) {
            NumberFormat percentInstance = DecimalFormat.getPercentInstance();
            percentInstance.setMinimumFractionDigits(valueAddedTaxPercentage.scale() - 2);
            value = percentInstance.format(valueAddedTaxPercentage);
          } else {
            value = "";
          }
          setHorizontalAlignment(JLabel.RIGHT);
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.