Normalized vectors not showing correctly

I am trying to get the direction that a cube is facing after rotation. I got the normalized vector as follows:

Vector3 forwardVector = transform.forward.normalized;
Debug.Log(forwardVector);

and this gives (0, 1, 0)

but when I print out the separate axes such as:

Debug.Log("X " + forwardVector.normalized.x);
Debug.Log("Y " + forwardVector.normalized.y);
Debug.Log("Z " + forwardVector.normalized.z);

I get

x = 0
y = 1
z = -1.19…E-07

Shouldn’t normalized round off to 1, -1 etc? Also, why is the individual z different from the reading as a whole (0, 1, 0)??

Thanks,
Syed

transform.forward does not need to be normalized.
E-07 is very small. Do you need better precision than 0.1 ppm?

1 Like

Rounding differences, thats -0.000000119 so thats basically 0.
there are a lot of numbers which can’t be converted to binary numbers exactly, so you often have some kind of rounding differences there. Thats why its often a bad way to compare something with 0, better say <= 0.000001 etc.

2 Likes

Ok. Thanks