# Floating Point Precision (fp:precise vs. fp:fast)

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.

## 1 Answer

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.

• -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. – Maik Semder Aug 24 '12 at 9:23
• 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. – postgoodism Aug 24 '12 at 16:04
• +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. – Ali1S232 Aug 24 '12 at 22:09
• @postgoodism Thanks for answering. Not ignoring your input. Just may wait another day or two to see if I get more responses. – Inisheer Aug 25 '12 at 6:59
• @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. – Nikos Oct 8 '18 at 18:28