0
\$\begingroup\$

From articles on the web, I found that floating point math generally has accuracy of at least 6 digits. With this in mind, is it possible to make Box2D which uses floats fully deterministic through the use of heavy rounding (i.e. 1st or 2nd decimal place)?

\$\endgroup\$
1
  • \$\begingroup\$ The question is why? It produces the same results for the same binary and the same machine. Why would you need more than that? \$\endgroup\$ – AturSams Feb 7 '15 at 19:07
1
\$\begingroup\$

The answer is an obvious no simply because "heavy rounding" doesn't alleviate the problem. Like you suggested the issue is with how floats behave on different architectures.

Lets say you round things up. :) What happens with very large numbers? They are still exactly the same. Large numbers behave differently too on different architectures. Fractions, are simply large numbers with a different exponent that determines the radix (floating) point position.

You would need to implement a cross-platform number. This is a known and well covered subject. Hint, there are performance issues.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.