A coworker and I have a disagreement about what can happen when comparing two floating-point numbers that have not been mathematically operated on. i.e. the numbers may have been moved around memory and/or cpu registers, but no math has been done on them. Maybe they have been put in a list and then removed or other various operations.
My experience has led me to believe that doing non-arithmetic operations on floating-point numbers should never change them or be subject to the same rounding errors as arithmetic operations. My coworker contents that the floating-point processing part of the cpu for some modern architectures is allowed to slightly corrupt the number such that equality checks fail, even when only storing/loading/moving the value.
For example, consider this C code:
float* a = (float*)malloc(sizeof(float));
float* b = (float*)malloc(sizeof(float));
*a = 1.0;
*b = 1.0;
int equal = *a == *b;
Are there any circumstances where equal
would not be 1
?