title: BigDecimal gives unexpected results for numbers larger than 7 or 0 decimal numbers
body: <p>While trying to calculate a ratio of the volume of 2 objects, I noticed some weirdness in the calculation, here is a sample you can run for yourself:</p>
  
  <pre><code>public class TestApplication {
  
    public static void main(String[] args) {
      BigDecimal first = BigDecimal.valueOf(21099000.0);
      BigDecimal second = BigDecimal.valueOf(13196000.0);
  
      System.out.println("First: " + first);
      System.out.println("Second: " + second);
      System.out.println("Division: " + first.divide(second, RoundingMode.HALF_UP).doubleValue());
    }
  }
  </code></pre>
  
  <p>And the result is:</p>
  
  <pre><code>First: 2.1099E+7
  Second: 1.3196E+7
  Division: 0.0
  </code></pre>
  
  <p>There are 3 ways I could make it give me the expected result </p>
  
  <p><strong>1. If I change the decimal part from 0 to 1 (or any non-0 number)</strong>:</p>
  
  <pre><code>First: 21099000.1
  Second: 13196000.1
  Division: 1.6
  </code></pre>
  
  <p><strong>2. If I divide the numbers beforehand (make them 7 digit numbers instead of 8)</strong>:</p>
  
  <pre><code>First: 2109900.0
  Second: 1319600.0
  Division: 1.6
  </code></pre>
  
  <p><strong>3. If I specify a scale doing division (<code>first.divide(second, 0, RoundingMode.HALF_UP</code>)</strong>:</p>
  
  <pre><code>First: 2.1099E+7
  Second: 1.3196E+7
  Division: 2.0
  </code></pre>
  
  <p>I thought that BigDecimal is backed by an integer and the numbers I used are way below 2 billion. Can anyone explain what makes these 3 cases different from the original result?</p>