News for hackers. Stuff that matters.
Re:Can we trust floating-point numbers? (2006) [pdf] by zwegner on Tuesday September 16, 2014 @04:13PM (#8326828)
Actually commutativity doesn't hold either, because of dealing with NaNs (at least on x86, on a quick search I can't find a reference for whether this behavior is part of IEEE 754 or just implementation defined). Operations with two NaNs will give the first operand. You can see this with a quick test program:

  #include <stdio.h>
  int main() {
      unsigned long long bits = 0x7FFC000000000000;
      double x = *(double *)&bits;
      bits += 1;
      double y = *(double *)&bits;
      double z = x + y, w = y + x;
      printf("%llx %llx\n", *(unsigned long long *)&z, *(unsigned long long *)&w);
  }
Of course, this probably doesn't matter for most applications.
Re:Can we trust floating-point numbers? (2006) [pdf] by stephencanon on Tuesday September 16, 2014 @04:16PM (#8326842)
IEEE-754 says that the result “should” be one of the two input NaNs. A platform could choose to e.g. take the NaN with the smaller payload to make * and + commutative, or it could simply define away NaN payloads entirely.