Floating point precision and physics calculations

Posted by Vee on Stack Overflow See other posts from Stack Overflow or by Vee
Published on 2011-06-21T08:19:41Z Indexed on 2011/06/21 8:22 UTC
Read the original article Hit count: 251

The gravity Vector2 in my physics world is (0; 0.1).

The number 0.1 is known to be problematic, since "it cannot be represented exactly, but is approximately 1.10011001100110011001101 × 2-4".

Having this value for the gravity gives me problems with collisions and creates quite nasty bugs. Changing the value to 0.11 solves these problems.

Is there a more elegant solution that doesn't require changing the value at all?

© Stack Overflow or respective owner

Related posts about c#

Related posts about game-development