title: How to round up and down numbers in Java
body: <p>Im trying to make my program evaluate a expression from left to right ignoring order of operations.</p>
  
  <p>E.g. 5/3+2*3 = 12</p>
  
  <p>Division should round up/down to the nearest integer. <strong>In this example, 5/3 should equate to 2 since 5/3 = 1.666 which rounds up to 2.</strong></p>
  
  <p>I have made a function which does computes the expression and it works perfectly up until the point the expression involves division. It doesn't round the number properly.
  This is how it computes the divion in my code:</p>
  
  <pre><code>            if (runningTotal % numbers.get(i + 1) &gt;= 5) {
                  runningTotal = (int) Math.ceil(runningTotal / numbers.get(i + 1));
              } else {
                  runningTotal = (int) Math.floor(runningTotal / numbers.get(i + 1));
              }
  </code></pre>
  
  <p>runningTotal is an int and numbers is an arraylist containing integers. Is there something wrong with my casting?</p>
  
  <p>Thanks for helping.</p>
  
  <p>EDIT = Figured it out myself. Forgot all about Math.round()....</p>