Shihui Guo

Double & Single Precision in Bullet

Numeric Stability is an annoying problem when we write algorithms, so here Bullet addresses this problem by defining a general type: btScalar, which can be either float or double. Therefore, it provides two ways for compiling, one is single precision (float), the other is double precision (double).

Obviously double precision is able to reduce the numeric error, thus improving the stability. From my experience, the speed performance is not significantly affected (simple scene tested).

To utilize the double precision, you need to first compile the libraries in double precision mode. Bullet uses cmake when compiling the libraries, turn on the option USE_DOUBLE_PRECISION by either using cmake gui, or editing CMakeList.txt directly


You may need to remove the CMakeCache.txt to make a successful recompilation.

To compile and link with doulbe-precision libraries, we use codeblocks to build different targets, one is single precision, the other is double precision.

First, add BT_USE_DOUBLE_PRECISION to the #defines option in build target
Screenshot from 2013-04-28 18:05:10

Second, change the compile and link paths to respective places. Remember that you got two different sets of libraries now.

Then you should see the differences. Go into the debug mode, check one variable, in single precision mode, it is normally 1e-10, but in double precision mode, it can be 1e-20, which makes huge differences.

A simple demo may also clarify the differences. Two videos are captured after two minutes simulation, the leg should swing back and forth in a single plane.

Single Precision

Double Precision