Examples of stripTrailingZeros()


Examples of java.math.BigDecimal.stripTrailingZeros()

            return new DecimalFormat("#,##0.0##############").format(val);
        }
        else if (val instanceof BigDecimal)
        {
            BigDecimal x = (BigDecimal) val;
            return x.stripTrailingZeros().toPlainString();
        }
        else if (val instanceof Number)
        {
            return new DecimalFormat("#,##0").format(val);
        }
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

            String message = String.format("Field %s requires a base 10 decimal, but found \"%s\"", name, svalue);
            throw new IllegalArgumentException(message);
        }

        // Split integer and decimal part
        bd = bd.stripTrailingZeros();
        String[] parts = bd.toPlainString().split("\\.");
        String integerPart = parts[0];
        String decimalPart = parts.length == 1 ? "0" : parts[1];

        if (integerPart.replaceFirst("-", "").length() > integerDigits)
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

            return new DecimalFormat("#,##0.0##############").format(val);
        }
        else if (val instanceof BigDecimal)
        {
            BigDecimal x = (BigDecimal) val;
            return x.stripTrailingZeros().toPlainString();
        }
        else if (val instanceof Number)
        {
            return new DecimalFormat("#,##0").format(val);
        }
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

            return new DecimalFormat("#,##0.0##############").format(val);
        }
        else if (val instanceof BigDecimal)
        {
            BigDecimal x = (BigDecimal) val;
            return x.stripTrailingZeros().toPlainString();
        }
        else if (val instanceof Number)
        {
            return new DecimalFormat("#,##0").format(val);
        }
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

            return new DecimalFormat("#,##0.0##############").format(val);
        }
        else if (val instanceof BigDecimal)
        {
            BigDecimal x = (BigDecimal) val;
            String s = x.stripTrailingZeros().toPlainString();
            if (s.contains("."))
            {
                String[] pieces = DECIMAL_REGEX.split(s);
                if (pieces.length != 2)
                {
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

        }
        else if (o instanceof BigDecimal)
        {
            BigDecimal d = (BigDecimal)o;
            builder.append('"');
            builder.append(d.stripTrailingZeros().toPlainString());
            builder.append('"');
        }
        else
        {
            builder.append(o.toString());
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

    if( t.isIntegerOnly() )
      return true;

    if( t.equals( Type.BIG_DECIMAL ) ) {
      BigDecimal decVal = (BigDecimal) n;
      return BigInteger.ZERO.equals(decVal.unscaledValue()) || decVal.stripTrailingZeros().scale() <= 0;
    }
    else if( t.equals( Type.RATIONAL ) ) {
      Rational ratVal = (Rational) n;
      if( compare( 1, ratVal.getDenominator() ) == 0 )
        return true;
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

            return new DecimalFormat("#,##0.0##############").format(val);
        }
        else if (val instanceof BigDecimal)
        {
            BigDecimal x = (BigDecimal) val;
            String s = x.stripTrailingZeros().toPlainString();
            if (s.contains("."))
            {
                String[] pieces = DECIMAL_REGEX.split(s);
                if (pieces.length != 2)
                {
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

                        try {
                            result = Decimal.value(on).divide(Decimal.value(arg));
                        } catch(ArithmeticException e) {
                            result = Decimal.value(on).divide(Decimal.value(arg), java.math.MathContext.DECIMAL128);
                        }
                        return context.runtime.newDecimal(result.stripTrailingZeros());
                    }
                }
            }));
    }
}// Decimal
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

    result = result.setScale(scale, RoundingMode.DOWN);

    if (result.compareTo(BigDecimal.ZERO) == 0)
      return BigDecimal.ZERO;

    result = result.stripTrailingZeros();

    return result;
  }
 
  /**
 
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.