News for hackers. Stuff that matters.
Re:Beware of Fast-Math by lo0dot0 on Saturday May 31, 2025 @09:51AM (#44144277)
While it technically correct to say this it also gets the wrong point across because it leaves out the fact that ordering changes create only a small difference. Other examples where arithmetic is not commutative, e.g. matrix multiplication , can create much larger differences.
Re:Beware of Fast-Math by kstrauser on Saturday May 31, 2025 @03:42PM (#44146532)
> ordering changes create only a small difference.

That can’t be assumed.

You can easily fall into a situation like:

  total = large_float_value
  for _ in range(1_000_000_000):
    total += .01
  assert total == large_float_value
Without knowing the specific situation, it’s impossible to say whether that’s a tolerably small difference.