2555 * × 10<sup>n</sup>)</tt> and scale {@code max(this.scale()-n, 2556 * 0)}. 2557 * 2558 * @param n number of places to move the decimal point to the right. 2559 * @return a {@code BigDecimal} which is equivalent to this one 2560 * with the decimal point moved {@code n} places to the right. 2561 * @throws ArithmeticException if scale overflows. 2562 */ 2563 public BigDecimal movePointRight(int n) { 2564 // Cannot use movePointLeft(-n) in case of n==Integer.MIN_VALUE 2565 int newScale = checkScale((long)scale - n); 2566 BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0); 2567 return num.scale < 0 ? num.setScale(0, ROUND_UNNECESSARY) : num; 2568 } 2569 2570 /** 2571 * Returns a BigDecimal whose numerical value is equal to 2572 * ({@code this} * 10<sup>n</sup>). The scale of 2573 * the result is {@code (this.scale() - n)}. 2574 * 2575 * @throws ArithmeticException if the scale would be 2576 * outside the range of a 32-bit integer. 2577 * 2578 * @since 1.5 2579 */ 2580 public BigDecimal scaleByPowerOfTen(int n) { 2581 return new BigDecimal(intVal, intCompact, 2582 checkScale((long)scale - n), precision); 2583 } 2584 2585 /** 2586 * Returns a {@code BigDecimal} which is numerically equal to 2587 * this one but with any trailing zeros removed from the 2588 * representation. For example, stripping the trailing zeros from 2589 * the {@code BigDecimal} value {@code 600.0}, which has 2590 * [{@code BigInteger}, {@code scale}] components equals to 2591 * [6000, 1], yields {@code 6E2} with [{@code BigInteger}, 2592 * {@code scale}] components equals to [6, -2] 2593 * 2594 * @return a numerically equal {@code BigDecimal} with any | 2555 * × 10<sup>n</sup>)</tt> and scale {@code max(this.scale()-n, 2556 * 0)}. 2557 * 2558 * @param n number of places to move the decimal point to the right. 2559 * @return a {@code BigDecimal} which is equivalent to this one 2560 * with the decimal point moved {@code n} places to the right. 2561 * @throws ArithmeticException if scale overflows. 2562 */ 2563 public BigDecimal movePointRight(int n) { 2564 // Cannot use movePointLeft(-n) in case of n==Integer.MIN_VALUE 2565 int newScale = checkScale((long)scale - n); 2566 BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0); 2567 return num.scale < 0 ? num.setScale(0, ROUND_UNNECESSARY) : num; 2568 } 2569 2570 /** 2571 * Returns a BigDecimal whose numerical value is equal to 2572 * ({@code this} * 10<sup>n</sup>). The scale of 2573 * the result is {@code (this.scale() - n)}. 2574 * 2575 * @param n the exponent power to ten to scale by 2576 * @return a BigDecimal whose numerical value is equal to 2577 * ({@code this} * 10<sup>n</sup>) 2578 * @throws ArithmeticException if the scale would be 2579 * outside the range of a 32-bit integer. 2580 * 2581 * @since 1.5 2582 */ 2583 public BigDecimal scaleByPowerOfTen(int n) { 2584 return new BigDecimal(intVal, intCompact, 2585 checkScale((long)scale - n), precision); 2586 } 2587 2588 /** 2589 * Returns a {@code BigDecimal} which is numerically equal to 2590 * this one but with any trailing zeros removed from the 2591 * representation. For example, stripping the trailing zeros from 2592 * the {@code BigDecimal} value {@code 600.0}, which has 2593 * [{@code BigInteger}, {@code scale}] components equals to 2594 * [6000, 1], yields {@code 6E2} with [{@code BigInteger}, 2595 * {@code scale}] components equals to [6, -2] 2596 * 2597 * @return a numerically equal {@code BigDecimal} with any |