title: Bad result from Java modulo operator?
body: <p>I suspect this has been asked before, but can't seem to find a question that matches... </p>
  
  <p>I'm using Scala, but I'm pretty sure this is just a Java problem... input values are doubles</p>
  
  <pre><code>println(28.0 / 5.6) 
  println(28.0 % 5.6)
  </code></pre>
  
  <p>The result of these lines is </p>
  
  <pre><code>5.0 
  1.7763568394002505E-15 
  </code></pre>
  
  <p>Which means that Java is performing the division correctly, but for some reason getting the modulo wrong, since the modulo should be 0 for any division problem that resolves to a whole number... </p>
  
  <p>Is there a workaround for this? </p>
  
  <p>Thanks!</p>