I apologize if this is a known issue or if I’m just being stupid but while doing some algebra to simplify some of the equations I’m using, I came across some odd inconsistencies which are shown below
int r = 10;
Debug.Log(r * 0.5f - r * 0.04f == r * 0.46f); // false
Debug.Log((r * 1 / 2) - (r * 4 / 100) == (r * 46 / 100)); // false
Debug.Log(r * (0.5f - 0.04f) == r * 0.46f); // true
Debug.Log(10 * 0.5f - 10 * 0.04f == 10 * 0.46f); // true
Hopefully I’m just overlooking something simple but to me, all 4 of these are equivalent unless I’m not accounting for rounding errors somewhere. The biggest issue and most confusing this is that when each part is broken into variables and their types compared, they are both System.Single’s and all result in 4.6.
So my question is why do the first 2 comparisons result in false while the second two return true? Especially the first and last. I’m using 5.3.4f1