I was doing some homework problems from my textbook and had a few questions on floating point rounding / precision for certain arithmetic operations.
If I have casted doubles from an int like so:
int x = random();
double dx = (double) x;
And let's say the variables y, z, dy, and dz follow the same format.
Then would operations like:
(dx + dy) + dz == dx + (dy + dz)
(dx * dy) * dz == dx * (dy * dz)
be associative? I know that if we have fractional representations, then it would not be associative because some precision will be lost due to rounding depending on which operands add / multiply each other. However, since these are casted from ints, I feel like the precision would not be a problem and that these can be associative?
And lastly, the textbook I'm using does not explain FP division at all so I was wondering if this statement was true, or at least just how floating point division works in general:
dx / dx == dz / dz
I looked this up online and I read in some areas like an operation like 3/3 can yield .999...9 but there wasn't enough information to explain how that happened or if it would vary with other division operations.