11
\$\begingroup\$

In C or C++, does the compiler option of floating point precision really make a difference in real world (small/indie) games?

From my observations, setting fp:fast is many times faster than fp:precise and from what I understand here ( https://stackoverflow.com/questions/6889522/fpfast-vs-fpprecise-what-kind-of-errors-can-i-encounter ) the precision difference between the two compiler options only changes from the 16th digit of a floating point number.

Has anyone encountered an example when using fp:fast went terribly wrong for 2D or 3D games?

Edit: To clarify, I am not asking about the precision of floating point values themselves (ie. float vs double vs decimal). Only about precision related to the compiler option.

\$\endgroup\$

1 Answer 1

13
\$\begingroup\$

Your interpretation of fp:fast vs fp:precise sounds suspicious; I'm sure there's more of an effect than just rounding error after the 16th decimal place. I refer you to Bruce Dawson's article on floating point precision for more details.

In general, floating-point precision error is definitely a real problem in game development. It's especially troublesome for physics programmers and for games with large worlds or long running times (on the order of weeks or months, like an MMO). Floating point precision errors most often manifest as simulation instability and jittery movement that gradually gets worse over time. If you're not seeing those sorts of artifacts in your game, and the performance increase is significant, then it should definitely be safe to stick with fp:fast.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ -1 Floating point precision is not a major problem in game development. Choosing wrong data types and lack of numerical knowledge and algorithms is the cause of all the problems mentioned in this post. All projects I participated used fp:fast with none of the problems mentioned. \$\endgroup\$ Commented Aug 24, 2012 at 9:23
  • 1
    \$\begingroup\$ Yes, our conclusions are the same. My point was that floating point precision can be a problem in certain areas of game development, and that's why (in those areas) you need the numerical knowledge and proper data types you mentioned. \$\endgroup\$
    – user19286
    Commented Aug 24, 2012 at 16:04
  • \$\begingroup\$ +1 for both great link, and for the answer you gave maik semder. I've also seen people struggling with those kind of errors, simply because they don't know what kind of operations they should use in their codes. \$\endgroup\$
    – Ali1S232
    Commented Aug 24, 2012 at 22:09
  • \$\begingroup\$ @postgoodism Thanks for answering. Not ignoring your input. Just may wait another day or two to see if I get more responses. \$\endgroup\$
    – Inisheer
    Commented Aug 25, 2012 at 6:59
  • \$\begingroup\$ @MaikSemder Basically just use fp:fast then, unless you really want the fp:precise if you notice various strange issues (could be noticed in complex computations in games, such as physics as @postgoodism said). Thanks, was wondering on this. \$\endgroup\$
    – KeyC0de
    Commented Oct 8, 2018 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .