Boost logo

Boost :

From: Kevin Atkinson (kevin_at_[hidden])
Date: 2003-02-26 21:28:39

Is there any interest in a fixed point math library. Using templates the
compiler can keep track of the radix point for you making using fixed
point math a lot less tedious and error prone.

Attached is a rudimentary implementation which would work acceptably when
the exponent is not too large or too small. If the exponent is smaller or
larger than the size of the underlying integer in bits this code will
likely behave badly.

I plan to use the attached code to avoid having to deal with serializing
floating point numbers. A exponent of -30 (-31 if using an unsigned 32
bit integer) is especially useful for representing numbers between 0 and
1. The precision will actually be a bit better than a 32 bit float since
the exponent does not have to be stored.

Comments on the code welcome. I am not a numerical analysis specialist so
don't expect me to write a fixed point library for anything beyond simple


Boost list run by bdawes at, gregod at, cpdaniel at, john at