Equality Bug Grasshopper and C#?

EqualityBug.gh (17.6 KB)

Hello Rhinoceros Forum!

I do not understand the behavior of equality in this script:

if (two vectors are perpendicular to each other) { the dot Product is equal to 0 and the cos of the angle is equal to the dot Product }
So Why the expression :
dotProduct == Math.Cos(angle) output False?
and why if I connect the outputs to a panel or to a Number component the output is correct as True?
Is this a Bug of the Equality in Grasshopper an in C#?

Thanks for any explanation!

because 0 is not the same as 0.0000000001 dues to numerical error. When comparing decimal number, ALWAYS use tolerence.

Instead of checking a == b
You should check if Math.Abs(a - b) < tolerance, where tolerance’s value might be some small number like 0.0001


Thanks Long!