Examples of stripTrailingZeros()


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

Examples of java.math.BigDecimal.stripTrailingZeros()

    */

    public DecimalValue(double in) throws ValidationException {
        try {
            BigDecimal d = new BigDecimal(in);
            value = d.stripTrailingZeros();
        } catch (NumberFormatException err) {
            // Must be a special value such as NaN or infinity
            ValidationException e = new ValidationException(
                    "Cannot convert double " + Err.wrap(in+"", Err.VALUE) + " to decimal");
            e.setErrorCode("FOCA0002");
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

                    return roundHalfToEven(scale);
                } else {
                    throw e;
                }
            }
            return new DecimalValue(scaledValue.stripTrailingZeros());
        }
    }

    /**
     * Determine whether the value is negative, zero, or positive
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

            || lowerCase.compareTo("\"-inf\"") == 0){
          return content2;
        }
        BigDecimal bd = new BigDecimal(content2.substring(1,
            content2.length() - 1));
        bd = bd.stripTrailingZeros();
        String bd_string = bd.toString();
        if (bd_string.compareTo("") == 0) {
          bd_string = "0";
        }
        // is bd_string distinguishable to an integer?
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()

      HiveDecimal hd = hdw.getHiveDecimal();

      BigDecimal readValue = hd.bigDecimalValue();

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

Examples of java.math.BigDecimal.stripTrailingZeros()

      final int scale) {
    final BigDecimal bigDividend = BigDecimal.valueOf(dividend);
    final BigDecimal bigDivisor = BigDecimal.valueOf(divisor);
    final BigDecimal quotient = bigDividend.divide(bigDivisor, scale,
        RoundingMode.HALF_UP);
    return quotient.stripTrailingZeros();

  }

  /**
   * Converts the string representation of a hexadecimal number to its binary
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

   */
  public static BigDecimal round(final double roundThis,
      final int decimalPlace) {
    final BigDecimal rounded = BigDecimal.valueOf(roundThis).setScale(
        decimalPlace, RoundingMode.HALF_UP);
    return rounded.stripTrailingZeros();
  }

  /**
   * Converts a short value to boolean.
   * <p>
 
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

   * @tests java.math.BigDecimal#stripTrailingZero(long)
   */
  public void test_stripTrailingZero() {
    BigDecimal sixhundredtest = new BigDecimal("600.0");
    assertTrue("stripTrailingZero failed for 600.0",
        ((sixhundredtest.stripTrailingZeros()).scale() == -2)
        );
   
    /* Single digit, no trailing zero, odd number */
    BigDecimal notrailingzerotest = new BigDecimal("1");
    assertTrue("stripTrailingZero failed for 1",
View Full Code Here

Examples of java.math.BigDecimal.stripTrailingZeros()

        );
   
    /* Single digit, no trailing zero, odd number */
    BigDecimal notrailingzerotest = new BigDecimal("1");
    assertTrue("stripTrailingZero failed for 1",
        ((notrailingzerotest.stripTrailingZeros()).scale() == 0)
        );
   
    /* Zero */
        //regression for HARMONY-4623, NON-BUG DIFF with RI
    BigDecimal zerotest = new BigDecimal("0.0000");
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.