title: Why am I getting a / by zero error?
body: <p>I'm trying to make a basic timing loop, but I keep getting </p>
  
  <pre><code>java.lang.ArithmaticException / by zero error
      at Timer.advanceTime(Timer.java:24)
  at Game.run(Game.java:79)
  at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>here is my code:</p>
  
  <pre><code>public class Timer {
          private static final long NS_PER_SECOND = 1000000000L;
          private static final long MAX_NS_PER_UPDATE = 1000000000L;
          private static final int MAX_TICKS_PER_UPDATE = 100;
          private float ticksPerSecond;
          private long lastTime;
          public int ticks;
          public float a;
          public float timeScale = 1.0F;
          public float fps = 0.0F;
          public float passedTime = 0.0F;
  
          public Timer(float ticksPerSecond) {
                  this.ticksPerSecond = ticksPerSecond;
                  this.lastTime = System.nanoTime();
          }
  
          public void advanceTime() {
                  long now = System.nanoTime();
                  long passedNs = now - this.lastTime;
                  this.lastTime = now;
  
                  if (passedNs &lt; 0L) passedNs = 0L;
                  if (passedNs &gt; 1000000000L) passedNs = 1000000000L;
                  this.fps = (float)(1000000000L / passedNs);
                  this.passedTime += (float)passedNs * this.timeScale * this.ticksPerSecond / 1.0E+009F;
                  this.ticks = (int)this.passedTime;
                  if (this.ticks &gt; 100) this.ticks = 100;
                  this.passedTime -= this.ticks;
                  this.a = this.passedTime;
          }
  }
  </code></pre>