I am running this code in Unity (Mono backend with .Net 4.x)
float a = 0.42434249394294f;
float b = 1 - a;
float sum = a + b;
bool compare1 = (a + b) >= 1f;
bool compare2 = sum >= 1f;
In Debugging (with Visual Studio), compare1
is false
while compare2
is true
.
How is this happening? Why are the last two lines different? I would think that sum == a + b
.