code: private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int scale, long preferredScale) {
          BigInteger qr[]; // quotient-remainder pair
          while (intVal.compareMagnitude(BigInteger.TEN) >= 0
                 && scale > preferredScale) {
              if (intVal.testBit(0))
                  break; // odd number cannot end in 0
              qr = intVal.divideAndRemainder(BigInteger.TEN);
              if (qr[1].signum() != 0)
                  break; // non-0 remainder
              intVal = qr[0];
              scale = checkScale(intVal,(long) scale - 1); // could Overflow
          }
          return valueOf(intVal, scale, 0);
      }
docs: Remove insignificant trailing zeros from this
  {@code BigInteger} value until the preferred scale is reached or no
  more zeros can be removed.  If the preferred scale is less than
  Integer.MIN_VALUE, all the trailing zeros will be removed.
  
  @return new {@code BigDecimal} with a scale possibly reduced
  to be closed to the preferred scale.