< prev index next >

src/java.base/share/classes/java/math/BigDecimal.java

Print this page
rev 58428 : [mq]: XXXXXXX-typos


3008      * the result is {@code (this.scale() - n)}.
3009      *
3010      * @param n the exponent power of ten to scale by
3011      * @return a BigDecimal whose numerical value is equal to
3012      * ({@code this} * 10<sup>n</sup>)
3013      * @throws ArithmeticException if the scale would be
3014      *         outside the range of a 32-bit integer.
3015      *
3016      * @since 1.5
3017      */
3018     public BigDecimal scaleByPowerOfTen(int n) {
3019         return new BigDecimal(intVal, intCompact,
3020                               checkScale((long)scale - n), precision);
3021     }
3022 
3023     /**
3024      * Returns a {@code BigDecimal} which is numerically equal to
3025      * this one but with any trailing zeros removed from the
3026      * representation.  For example, stripping the trailing zeros from
3027      * the {@code BigDecimal} value {@code 600.0}, which has
3028      * [{@code BigInteger}, {@code scale}] components equals to
3029      * [6000, 1], yields {@code 6E2} with [{@code BigInteger},
3030      * {@code scale}] components equals to [6, -2].  If
3031      * this BigDecimal is numerically equal to zero, then
3032      * {@code BigDecimal.ZERO} is returned.
3033      *
3034      * @return a numerically equal {@code BigDecimal} with any
3035      * trailing zeros removed.
3036      * @since 1.5
3037      */
3038     public BigDecimal stripTrailingZeros() {
3039         if (intCompact == 0 || (intVal != null && intVal.signum() == 0)) {
3040             return BigDecimal.ZERO;
3041         } else if (intCompact != INFLATED) {
3042             return createAndStripZerosToMatchScale(intCompact, scale, Long.MIN_VALUE);
3043         } else {
3044             return createAndStripZerosToMatchScale(intVal, scale, Long.MIN_VALUE);
3045         }
3046     }
3047 
3048     // Comparison Operations
3049 
3050     /**




3008      * the result is {@code (this.scale() - n)}.
3009      *
3010      * @param n the exponent power of ten to scale by
3011      * @return a BigDecimal whose numerical value is equal to
3012      * ({@code this} * 10<sup>n</sup>)
3013      * @throws ArithmeticException if the scale would be
3014      *         outside the range of a 32-bit integer.
3015      *
3016      * @since 1.5
3017      */
3018     public BigDecimal scaleByPowerOfTen(int n) {
3019         return new BigDecimal(intVal, intCompact,
3020                               checkScale((long)scale - n), precision);
3021     }
3022 
3023     /**
3024      * Returns a {@code BigDecimal} which is numerically equal to
3025      * this one but with any trailing zeros removed from the
3026      * representation.  For example, stripping the trailing zeros from
3027      * the {@code BigDecimal} value {@code 600.0}, which has
3028      * [{@code BigInteger}, {@code scale}] components equal to
3029      * [6000, 1], yields {@code 6E2} with [{@code BigInteger},
3030      * {@code scale}] components equal to [6, -2].  If
3031      * this BigDecimal is numerically equal to zero, then
3032      * {@code BigDecimal.ZERO} is returned.
3033      *
3034      * @return a numerically equal {@code BigDecimal} with any
3035      * trailing zeros removed.
3036      * @since 1.5
3037      */
3038     public BigDecimal stripTrailingZeros() {
3039         if (intCompact == 0 || (intVal != null && intVal.signum() == 0)) {
3040             return BigDecimal.ZERO;
3041         } else if (intCompact != INFLATED) {
3042             return createAndStripZerosToMatchScale(intCompact, scale, Long.MIN_VALUE);
3043         } else {
3044             return createAndStripZerosToMatchScale(intVal, scale, Long.MIN_VALUE);
3045         }
3046     }
3047 
3048     // Comparison Operations
3049 
3050     /**


< prev index next >