title: Remove decimal ending zeros from BigDecimal
body: <p>I write test and want compare <em>BigDecimal</em> result with expected value.
  I want use method <code>Assert.assertEquals(BigDecimal, BigDecimal)</code> because if drop it show exact compared values and in eclipse I can show comparison window.</p>
  
  <p>So in code i have method that returns <em>BigDecimal</em> rounded to 2 decimal places.
  In test case i now it return number without non zero decimal digits. So i want create <em>BigDecimal</em> with scale 0 and trim returned <em>BigDecimal</em> to same scale.</p>
  
  <p>For more complexity I have now method <code>getDecimal(Object [,Optionaly int scale])</code> that create <em>BigDecimal</em> from any object with correct <code>toString()</code> value with default scale 99. I use it in main "heavy" code so this method must be very quick (Not necesary create another objects, dont use regexp, etc.).</p>
  
  <p>So simple question is: how to modify <em>BigDecimal</em> instance to trim ending decimal zeros by minimal load.</p>
  
  <p>Want srip like this</p>
  
  <pre><code>0.010 -&gt; 0.01
  5.000 -&gt; 5
  100 -&gt; 100   not 1E+2
  </code></pre>
  
  <p>Resp:</p>
  
  <pre><code>someTrim(new BigDecimal("100.00")).equals(new BigDecimal(100))
  </code></pre>
  
  <p>Do math somthing like </p>
  
  <pre><code>100.00 / (2, 99, DOWN) * 50.00 -&gt; 2500
  </code></pre>
  
  <p>And my code looks like </p>
  
  <pre><code>public static BigDecimal getDecimal( Object value ) {
      // null here probably work beter, but dont want number longer then 99 decimal digits
      return getDecimal( value, 99 );
  }
  
  public static BigDecimal getDecimal( Object value, Integer scale ) {
      if ( value == null )
          return null;
  
      BigDecimal result = ( value instanceof BigDecimal ) ? ( BigDecimal ) value : new BigDecimal( value.toString() );
  
      if ( scale == null )
          return result;
  
      return result.setScale( scale, DOWN );
  }
  
  // Main heavy method could call this 100 000 times per tenant (cca 1500 tenants), of course not expect all in same time, but can severals
  public static myModify(E entity){
      return myModify( entity.getValue(), entity.getDivisor(), entity.getMultiplicator() );
  }
  
  public static myModify( BigDecimal value, Integer divisor, BigDecimal multiplicator){
       return value.divide( getDecimal(divisor), 99, RoundingMode.DOWN ).multiply( multiplicator );
  }
  
  @Test
  public void myModifyTest(){
      // Constructor have param: value, divisor, multiplicator
      E entity = new E(new BigDecimal("100.00"), 2, new BigDecimal("50.00"));
      // Should pass
      Assert.assertEquals(getDecimal(100), entity);
      // Should drop: java.lang.AssertionError: expected:&lt;50&gt; but was:&lt;100&gt;
      Assert.assertEquals(getDecimal(50), entity);
      // Not want: java.lang.AssertionError: expected:&lt;5E+1&gt; but was:&lt;1E+2&gt;
  }
  </code></pre>
  
  <p>Maybe exist another junit comparsion method that drop same error, but i don't know it</p>
  
  <p>Thanks for help. Pavel</p>