Error in localPosition

Hello
I have an issue with the localPosition. It seem to be incorrect
When I make
parent.position - (child.position - child.localPosition);
I should get 0 but I have 0.206761
Any idea?
Thanks

The results depend on the range you have your numbers in. floats, which are used for Unity’s Vector structs, are limited to the 32 bits they have to represent a number that can be very large (1000000000) or have very small digits (0.000000001).
Because float numbers can grow a lot in these two directions, there is no set range of numbers they can properly represent, like integers have. As a result, very large floats become more and more imprecise.

You can test this like this:

var f1 = 123456789f + 1f + 1f;
var f2 = 123456789f + 1f;
if(f1 == f2)
{
  Debug.Log("wat");
}

On the same note, if your objects are at a position very far away from (0,0,0), subtracting two positions might very well lead to incorrect results. This is no bug, it’s simply due to the limited nature of floating point numbers.