title: Modulus with doubles in Java
body: <p>How do you deal with Java's weird behaviour with the modulus operator when using doubles?</p>
  
  <p>For example, you would expect the result of <code>3.9 - (3.9 % 0.1)</code> to be <code>3.9</code> (and indeed, <a href="http://www.google.com/search?q=3.9+-+%283.9+%25+0.1%29" rel="noreferrer">Google</a> says I'm not going crazy), but when I run it in Java I get <code>3.8000000000000003</code>.</p>
  
  <p>I understand this is a result of how Java stores and processes doubles, but is there a way to work around it?</p>