# Vector4 Rounding Errors with Colors

**URL:** <https://forum.defold.com/t/vector4-rounding-errors-with-colors/70490>\
**Category:** Questions\
**Created:** [March 6, 2022, 9:16am UTC](https://forum.defold.com/t/vector4-rounding-errors-with-colors/70490 "2022-03-06T09:16:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [March 6, 2022, 9:37am UTC](https://forum.defold.com/t/vector4-rounding-errors-with-colors/70490/2 "2022-03-06T09:37:49Z")

</div>

This is due to floating point precision.

You can [read more about it here](https://forum.defold.com/t/floating-point-precision/11247)

In short, unless you are certain that the number can be accurately represented (e.g. whole numbers), you are best advised to not do “==” comparisons with floating point numbers.

An alternative is to see if the number “is close” to the number you desired: `if abs(a - b) < 0.001 then ...`. Although I’d look into other ways of detecting these scenarios instead.

---

_[View the full topic](https://forum.defold.com/t/vector4-rounding-errors-with-colors/70490)._
