these don't hold for floats even though most math formulas and compiler optimizations rely on these to hold.
Most compilers have an option like -fassociative-math that explicitly allows optimization under the assumption of associativity and distributivity.
Real programmers use fixed point representation and make sure the bounds don't overflow/underflow unexpectedly.
So you complain that floating-point is bad because it's not associative but then suggest that we use fixed-point instead (which is also nonassociative), but it's okay, because it's fine as long as you do thing that programmers rarely do.
Let's ban all hardware floating-point implementation : Just imagine future alien archeologists having a laugh at us when they look at our chips and think "no wonder they were doomed they can't even do a+b right : its foundations were built on sand".
Ah, you're the kind of person who sees that 0.1 + 0.2 != 0.3 and decides to go on a crusade against floating-point because of it. By the way, fixed point has that exact same bug: it's a fault that is caused by the base being different more than the other principles of the floating-point type.
Floating-point has trade-offs; a good programmer understands the trade-offs of floating-point and will not ask more of it than it can provide.
Comments
Most compilers have an option like -fassociative-math that explicitly allows optimization under the assumption of associativity and distributivity.
So you complain that floating-point is bad because it's not associative but then suggest that we use fixed-point instead (which is also nonassociative), but it's okay, because it's fine as long as you do thing that programmers rarely do.
Ah, you're the kind of person who sees that 0.1 + 0.2 != 0.3 and decides to go on a crusade against floating-point because of it. By the way, fixed point has that exact same bug: it's a fault that is caused by the base being different more than the other principles of the floating-point type.
Floating-point has trade-offs; a good programmer understands the trade-offs of floating-point and will not ask more of it than it can provide.