title: Java percentage calculation not processing and I can't figure out why
body: <p>A snippet of code is below:</p>
  
  <pre><code>System.out.println("Calc: " + totalMs[0] + " divided by " + totalTestMs + " times 100");
  System.out.println("Calc 2: " + totalBits[0] + " divided by " + totalCount[0] + " divided by 1000000");
  
  DecimalFormat df = new DecimalFormat("0.00");
  
  String b1 = "0", b2 = "0", b3 = "0", b4 = "0", b5 = "0", b6 = "0", b7 = "0", b8 = "0", b9 = "0", b10 = "0";
  String b1Pct = "0";
  
  if (totalCount[0] &gt; 0) { 
      b1Pct = df.format((totalMs[0]/totalTestMs)*100);
      b1 = df.format((totalBits[0]/totalCount[0])/1000000); 
  }
  </code></pre>
  
  <p>Calc fails and Calc 2 passes. The Output shown by the above System prints is:</p>
  
  <p><img src="https://i.stack.imgur.com/5N3Ra.png" alt="enter image description here"></p>
  
  <p>As you can see the figures appear to be passing correctly. However, when I System output the <strong>b1Pct</strong> result it states "0.0". When in this case it should be 22.73.</p>
  
  <p>I'm sure it's something simple but I can't figure it out. Even more confusing as the second one is correct!</p>