Hello,
I need to solve some partial differential equations using
java (using finite difference). In past I used to ignore this problem with double precision in Java. but now I am caught.
I have variable t which I increase 0.1 each time for example. Now when I print t:
t=0.1
t=0.2
t=0.30000000000000004
t=0.4
t=0.5
t=0.6
t=0.7
t=0.7999999999999999
t=0.8999999999999999
t=0.9999999999999999
t=1.0999999999999999
...
Then I use the t in my calculations. In addition to the difference of above numbers to what I need for my calculations (which is small) these are not the numbers I need. I need to find the result for t=1.1 entry (by comparing t to 1.1 in an results array but there is no 1.1).
How can I deal with this? And generally how can I compare double variables (if it is possible at all).
Regards,
Mac