Examples of stripTrailingZeros()


Examples of java.math.BigDecimal.stripTrailingZeros()

   
    /* Zero */
        //regression for HARMONY-4623, NON-BUG DIFF with RI
    BigDecimal zerotest = new BigDecimal("0.0000");
    assertTrue("stripTrailingZero failed for 0.0000",
        ((zerotest.stripTrailingZeros()).scale() == 0)
        );   
 

  public void testMathContextConstruction() {
        String a = "-12380945E+61";
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

        if (num instanceof BigDecimal) {
            bigDecimal = (BigDecimal) num;
        } else {
            bigDecimal = new BigDecimal(num.toString());
        }
        bigDecimal = bigDecimal.stripTrailingZeros();

        int intLength = bigDecimal.precision() - bigDecimal.scale();
        if (integral >= intLength) {
            int factionLength = bigDecimal.scale() < 0 ? 0 : bigDecimal.scale();
            return fractional >= factionLength;
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

      HiveDecimal hd = hdw.getHiveDecimal();

      BigDecimal readValue = hd.bigDecimalValue();

      assertEquals(d.toBigDecimal().stripTrailingZeros(),
          readValue.stripTrailingZeros());
    }
}
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

                    case 2: result = first.add(second); break;
                    case 3: result = first.subtract(second); break;
                    default: throw new IllegalStateException();
                }
                StringBuffer buffer = new StringBuffer();
                matcher.appendReplacement(buffer, result.stripTrailingZeros().toPlainString())
                        .appendTail(buffer);
                queryString = buffer.toString();
            }
        }
        return queryString;
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()

        }
        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()

            return null;
        }
        BigDecimal bd = new BigDecimal(decimal);
        // if the scale is too large, check for trailing zeros
        if (bd.scale() > kDefaultScale) {
            bd = bd.stripTrailingZeros();
            if (bd.scale() > kDefaultScale) {
                throw new IOException("Decimal " + bd + " has more than " + kDefaultScale + " digits of scale");
            }
        }
        // enforce scale 12 to make the precision check right
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()

            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()

            BigDecimal minBD = BigDecimal.valueOf(range.getMinimum());
            BigDecimal rangeBD = BigDecimal.valueOf(range.getMaximum()).subtract(minBD).add(BigDecimal.ONE);
            BigDecimal valueBD = BigDecimal.valueOf(value).subtract(minBD);
            BigDecimal fraction = valueBD.divide(rangeBD, 9, RoundingMode.FLOOR);
            // stripTrailingZeros bug
            return fraction.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : fraction.stripTrailingZeros();
        }

        /**
         * Converts a fraction from 0 to 1 for this field to a value.
         * <p>
 
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.