Floating point numbers are not exact due to its limited precision. My question is: is multiplication commutative in floating number computer calculation?
For example
double a = ..;
double b = ...;
double c = a * b;
double d = b * a;
if (c == d)
cout << "Yes, great floating";
According to Wikipedia, yes, float multiplication is commutative.
While floating-point addition and multiplication are both commutative (a + b = b + a and a×b = b×a), they are not necessarily associative. That is, (a + b) + c is not necessarily equal to a + (b + c).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With