I'm looking for a C++ template library which implements operations on continuous开发者_StackOverflow社区 signals represented in integer types with their resolutions (fixed point numbers).
e.g: foo, bar, baz are int with 10, 5 and 2 count/unit resolution
foo = 4; bar = 3; baz = foo * bar; printf("%d %d %d\n", foo, bar, baz);
results: 40 15 24
(foo = 4 * 10, bar = 3 * 5, baz = foo / 10 * bar / 5 * 2)
This is an old C++ library that supports mixing numbers of different precisions. The precisions have to be power of 10.
http://www.efgh.com/software/fixed.htm
If you want math functions (sin, cos, tan) you can try out this library:
http://www.trenki.net/content/view/17/1/
This does not allow you to mix precisions.
Disclaimer: I haven't used any of these !
精彩评论