How to detract vector's dot product to 0?

float dot = Vector3.Dot(vec, vecNormal);

vec -= dot * vecNormal.normalized;

//Now, expecting this to be true:
//Vector3.Dot(vec, vecNormal) == 0

I’m trying to detract the vecNormal’s axis from vec. Doing this I presume I would be able to make the dot product 0, but it doesn’t work. How do I make it so? What am I missing?

but it doesn’t work

That’s not true. It does work, but it’s most likely not exactly 0 due to floating point rounding errors.

Note that Unity already has a method that performs the projection you’re looking for: Vector3.ProjectOnPlane. (This is literally how the method is defined).

Since you said you expect the expression to be true, I would highly recommend watching this numberphile video on floating point numbers.