I've prepared a portable c++ library to work with fixed-point data types, using an object-oriented intuitive approach.
Complete source code and doxygen documentation are available.
Feel free to use it in your own fixed-point projects! I've compiled it with vc++ (windows), gcc 4.0 (ubuntu and mac os x).
http://ag-works.net/source.fixpoint.htm
Quickstart usage example:
Code: Select all
TFix32<28> a = 0.500000; // 32 bits fixed-point values on the stack,
TFix32<28> b = 0.170000; // with 28 decimal bits
TFix32<28> c = 0.250000;
TFix32<28> acc = a + b;
// Evaluate complex expressions using infix overloaded operators
// with maximum precision and same performance of classic macros (MUL,DIV,..)
TFix32<28> out = ((a - c) / (a + c)) * (acc >> 1);
- - Object incapsulation of the fixed-point data type
- Template parameters specify decimal precision
- Use infix overloaded operators (+,*,..) in complex expressions instead of postfix functions (MUL,DIV,..)
- Template optimized inlines produce fastest code (code bloat is prevented)
- Easy and precise conversion among different decimal resolutions
- Math functions (interoperating with standard data types)
- Vector processing
Alessandro


