sgeos said:
My bad. Sorry. Should have double checked on paper
before posting. =P
I tend to think of subtraction as shorthand for + -value, in
which case the above resolves to:
a + -b + c
Unless I've made a logic error, the following should be true:
I think you are making the logic error of assuming that identities that
are true in some arithmetic systems, such as real number arithmetic,
necessarily apply to other arithmetic systems.
(a + -b) + c == a + (-b + c)
public class AssociativityTest {
public static void main(String[] args) {
double a = 1e-30;
double b = 1;
double c = 1;
System.out.printf("(a + -b) + c: %g, a + (-b + c): %g",
(a + -b) + c,
a + (-b + c)
);
}
}
prints:
(a + -b) + c: 0.00000, a + (-b + c): 1.00000e-30
Likewise, I think of division as shorthand for * (1/value).
public class IntDivideTest {
public static void main(String[] args) {
System.out.printf("80/20: %d, 80*(1/20): %d", 80/20, 80*(1/20));
}
}
prints:
80/20: 4, 80*(1/20): 0
Patricia