changeset 53225:b732de3068f4

8183912: java.math.BigDecimal.movePointLeft() should return this if called with zero argument Reviewed-by: rriggs
author bpb
date Wed, 19 Dec 2018 11:44:57 -0800
parents 9b0d6ecd8e45
children 11033c4ada54
files src/java.base/share/classes/java/math/BigDecimal.java
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/math/BigDecimal.java	Wed Dec 19 14:02:19 2018 -0500
+++ b/src/java.base/share/classes/java/math/BigDecimal.java	Wed Dec 19 11:44:57 2018 -0800
@@ -2871,6 +2871,8 @@
      * @throws ArithmeticException if scale overflows.
      */
     public BigDecimal movePointLeft(int n) {
+        if (n == 0) return this;
+
         // Cannot use movePointRight(-n) in case of n==Integer.MIN_VALUE
         int newScale = checkScale((long)scale + n);
         BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0);
@@ -2893,6 +2895,8 @@
      * @throws ArithmeticException if scale overflows.
      */
     public BigDecimal movePointRight(int n) {
+        if (n == 0) return this;
+
         // Cannot use movePointLeft(-n) in case of n==Integer.MIN_VALUE
         int newScale = checkScale((long)scale - n);
         BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0);