Comparing two numbers algorithm not working c#

Welcome to the computing world of floating-points. Especially after operations on floating point numbers you can not directly compare numbers like that. You have to do a “fuzzy equal” check instead. There are several ways to do that, the simplest one is to subtract the two numbers, take the absolute value of that result and see if that is smaller than epsilon, a small value you choose to work well enough for your purposes.

Search our forum (and the internet) for past discussions on this topic.

My favorite post on this issue is still this Mesh.Vertices accuracy seems wrong, why? Letwory, along with the reply to it.

1 Like