title: BigDecimal scale for large numbers
body: <p>I'm trying to understand the scale for a BigDecimal but it acts weird and I can't understand why. Here's a couple of examples:</p>
  
  <pre><code>Double d = new Double(1000000d);
  int scale = new BigDecimal(d.toString()).scale();
  </code></pre>
  
  <p>The scale in this example will be 1 which is correct to me.
  The result of d.toString() is "1000000.0".</p>
  
  <pre><code>Double d = new Double(10000000d);
  int scale = new BigDecimal(d.toString)).scale();
  </code></pre>
  
  <p>The scale in this example will be -6. Can anyone explain why?
  The result of d.toString() is "1.0E7".</p>
  
  <p>I thought the number of digits caused this but if I go:</p>
  
  <pre><code>Double d = new Double(11111111d);
  int scale = new BigDecimal(d.toString()).scale();
  </code></pre>
  
  <p>Expected a scale of -8 but suddenly it's 0.
  The result of d.toString() is "1.1111111E7".</p>
  
  <p>These different scales make no sense to me after reading the Javadoc of scale():</p>
  
  <blockquote>
    <p>Returns the scale of this BigDecimal. If zero or positive, the scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the scale. For example, a scale of -3 means the unscaled value is multiplied by 1000.</p>
  </blockquote>
  
  <p>I'd very much appreciate an explanation how BigDecimal behaves when the numbers are large.</p>
  
  <p>Thanks in advance!</p>