# Same Array item and Search item but no match

Hi!

Trying to learn UE4. Not going well. Basically I am rotating a vector. Adding it to an array. And then I try to find it in the array again. But despite the array item and my search item being identical it tells me the search item does not exist in the array. What am I doing wrong?

• Vector to be added: X=-0.000 Y=100.000 Z=100.000
• Vector in array: X=-0.000 Y=100.000 Z=100.000
• Vector that I search for: X=0.000 Y=100.000 Z=100.000
• What I find: -1 (no match)

I also tried adding a minus sign in front of the 0 and it is automatically removed but when I search it is still there, however I still don’t get a match:

• Vector to be added: X=-0.000 Y=100.000 Z=100.000
• Vector in array: X=-0.000 Y=100.000 Z=100.000
• Vector that I search for: X=-0.000 Y=100.000 Z=100.000
• What I find: -1 (no match)

It seems like a really simple thing to do. Add item to array, find the same item in the array again. But I’ve spent hours trying to solve this problem now. Please help.

Some years later, and with more knowledge, I will answer my own question. It has to do with floating point precision. Calculations with float numbers are not as accurate as one might think because of how computers handle decimal places. The vector rotation I did introduced rounding errors. Had I used the builtin debugger I would have easily seen that.

But instead I used “Print String” to debug. But when converting vector to string it automatically rounds the vector, hiding the rounding error, making the two vectors look the same. Not easy for a beginner to understand…

The built in Equal(vector) function for comparing vectors allows you to specify an error tolerance. An actual solution to the asked use scenario, could be to implement your own Find function for vector arrays, using Equal(vector) to do the comparison.