I am trying to determine if vA and vB (both Vector3) are the same and the comparison fails when it should not. It fails because (vA-vB).x is 0.000000238 when it should be 0.0.
Printing vA, vB, vA-vB using ToString(“f50”) on each x,y,z gives:
vA:
(3.00000000000000000000000000000000000000000000000000,
5.00000000000000000000000000000000000000000000000000,
5.00000000000000000000000000000000000000000000000000)
vB:
(3.00000000000000000000000000000000000000000000000000,
5.00000000000000000000000000000000000000000000000000,
5.00000000000000000000000000000000000000000000000000)
vA-VB:
(0.00000023841860000000000000000000000000000000000000,
0.00000000000000000000000000000000000000000000000000,
0.00000000000000000000000000000000000000000000000000)
(vA-vB).magnitude == 2.35E-7; //is true
Mathf.Approximately((vA-vB).magnitude,0); //is false
I know there is floating point imprecision, but I would think that would be near Mathf.Epsilon, 1.401298E-45, not 2.35E-7.
Any tips on how to get around this issue? Anyone think its a bug?