In general, the order in which floating point values are added is important. An entry point for own research could be http://en.wikipedia.org/wiki/Loss_of_significance . To summarize the basic caveat, in an oversimplified form:
Due to the limited number of significant bits, you have to assume something like
100000000000000000.0 + 1.0 = 100000000000000000.0
in floating-point computations. Consequently, when computing
100000000000000000.0
+ 1.0
- 100000000000000000.0
the result will be 0.0
- and thus, be different from
100000000000000000.0
- 100000000000000000.0
+ 1.0
where the result will be 1.0
.