By way of explanation, let's look at base ten arithmetic that
you should have learned in grade school (or whatever you guys call it over in England
). What is 1 / 3? You might say it's 0.3333, but that is only rounded to four decimal places and no longer the exact value of one-third. Binary arithmetic used by a computer suffers from similar problems. Fractional values are subject to round off error when stored in a binary format. If you want more technical details about this, you should google for "IEEE floating point numbers" or something similar. IEEE made the standard that most computers use for storing floating point numbers. There should be plenty of information on the Net about the particular problem you have encountered here. Also, this topic has been discussed previously here, so you may want to use the Search tool to see what has been said about it. If you don't find anything on this particular forum, you may want to try searching "Java In General (intermediate)".
HTH
Layne