preventing rounding problems with doubles
I have a problem with an algorithm I wrote: I must use double representation for the values but different sequences of arithmetic operations which are supposed to result in equal numbers are delivering slightly different numbers, e.g. 4*10^(-12) difference. This is definitely due to the binary representation of the numbers but is it somehow possible to circumvent these problems?
-1629.000+1629.000 = -4.3200998334214e-012
Right now I am using a lot of rounding to decimal places but there are still some points I am missing. Is there another way to generally prevent these problems?
Thanks a lot for considering my question!!!