1
$\begingroup$

Does the associative/commutative/distributive/etc property hold for arithmetic performed with IEEE 754 floats?

Obviously the answer is no to most of those questions, but do any of the properties of standard arithmetic hold? How can one formulate proofs (or at least proof-like statements) explaining why any particular property does or does not hold?

$\endgroup$
  • 2
    $\begingroup$ A counterexample suffices to prove that a property doesn't hold (e.g., floats $x$, $y$ and $z$ such that $x+(y+z)\neq (x+y)+z$). As for proving that properties do hold, what are you looking for? A proof of $X$ is a convincing argument that $X$ is true. How one formulates a convincing argument that something is true depends very much on what that thing is. If you're asking for a proof or counterexample for each of the three-plus-etc properties, that's too much for a single question. $\endgroup$ – David Richerby Apr 18 '18 at 17:48
4
$\begingroup$

The IEEE 754 standard defines exactly how floating-point arithmetic is performed. For many interesting theorems, you will need to examine the exact definition. For some less interesting ones, like a+b = b+a or ab = ba, all you need to know that IEEE 754 always calculates the exact result, rounded in a deterministic way. For non-theorems, like (a+b)+c = a+(b+c), which is false, all you need is a counterexample which is usually easy to find.

$\endgroup$
0
$\begingroup$

Check e.g. Goldberg's "What every computer scientist should know about floating point". Heavy reading, but a must.

$\endgroup$
  • $\begingroup$ I've read it. The only direct reference to the arithmetic axioms is a single sentence: "Due to roundoff errors, the associative laws of algebra do not necessarily hold for floating-point numbers." It later mentions "the importance of preserving parentheses". From this I've come to the conclusion that the reason why any axiom does or does not hold is down to whether or not it changes the order of operations. Is that more or less correct? $\endgroup$ – tel Apr 29 '18 at 1:41
  • $\begingroup$ @tel, associative laws don't hold. Others do, like $x - x = 0$, $x + 0 = x$, $1 \cdot x = x$, $x + y = y + x$. $\endgroup$ – vonbrand May 2 '18 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.