Article Rich Public

Here's a quick library for a class "Fixed" that can replace "double" or "float" in C++ code but do arithmetic in fixed point, with 16 bits to the right of the "binary point".

Everything is in one header file. There is another file that tests it.

PLEASE TEST IT CAREFULLY if you try using it! I'm sure my testing is insufficient.

  • fixed.h -- include this C++ header, then use the data type "Fixed"
  • test.cpp -- this C++ file is the test
  • matrix.cpp -- a benchmark routine; compile with -DM=2000 and try -DTYPE=Fixed, int, float, or double. You might also try options like: -O3 -march=pentium3 -freg-struct-return