1
General discussions / Vector's equality and inequality operators
« on: September 12, 2011, 08:43:44 am »
Hello everybody. Thanks for SFML loking forward to new release and more tutorials like Joystick.
Anyway I see this in Vector2.inl and Vector3.inl:
This will not work reliable for Floats but only Integers.
I found article which helped me and maybe you too:
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
Anyway I see this in Vector2.inl and Vector3.inl:
Code: [Select]
template <typename T>
bool operator ==(const Vector2<T>& V1, const Vector2<T>& V2)
{
return (V1.x == V2.x) && (V1.y == V2.y);
}
template <typename T>
bool operator !=(const Vector2<T>& V1, const Vector2<T>& V2)
{
return (V1.x != V2.x) || (V1.y != V2.y);
}
template <typename T>
bool operator ==(const Vector3<T>& V1, const Vector3<T>& V2)
{
return (V1.x == V2.x) && (V1.y == V2.y) && (V1.z == V2.z);
}
template <typename T>
bool operator !=(const Vector3<T>& V1, const Vector3<T>& V2)
{
return (V1.x != V2.x) || (V1.y != V2.y) || (V1.z != V2.z);
}
This will not work reliable for Floats but only Integers.
I found article which helped me and maybe you too:
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm