title: java.lang.NumberFormatException: Infinite or NaN at java.math.BigDecimal
body: <p>I have the following code </p>
  
  <pre><code>double a = 29.0;
  double b = 9.0;
  double c = 4.0;
  BigDecimal sum= new BigDecimal(0.0);
  sum=sum.add(new BigDecimal(Math.log10((a)/(b*c) /Math.log10(2)));
  </code></pre>
  
  <p>I tried to use double for sum instead of BigDecimal but it gives me infinity as a result. when I used BigDecimal I got no results but error says:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NumberFormatException: Infinite or NaN
        at java.math.BigDecimal.(Unknown Source)</p>
  </blockquote>
  
  <p>any help please cause this is the first time I deal with large numbers
  Note: a, b, anc c values will be changed through a loop and because of that I have to save the total sum. </p>