简体   繁体   English

不同小数点的定点最佳算法

[英]Fixed point optimum algorithm for different decimal points

So I have a 32 bit processor I can program to in C that needs to be used with fixed point for speed. 因此,我有一个可以在C中编程的32位处理器,该处理器需要与定点一起使用以提高速度。

I understand fixed point representation and basic implementation. 我了解定点表示法和基本实现。 What Im looking for is how to combine numbers with different number of decimal bits. 我正在寻找的是如何将具有不同十进制位数的数字组合在一起。

Lets say I sum Q10 + Q10 I would use Q10 as the sum. 可以说我求和Q10 + Q10,我将使用Q10作为总和。 What If I sum Q10 and Q20? 如果我将Q10和Q20相加怎么办? Is the an algorithm that takes into account both numbers and chooses the appropriate Qx value to minimize precision loss and overflows? 该算法是否同时考虑了两个数字并选择合适的Qx值以最大程度地降低精度损失和溢出? I basically need addition, subtraction, multiplication and division. 我基本上需要加,减,乘和除。

The issue is that my operations may look like: 问题是我的操作可能类似于:

2*3.14159*50*1e-4*10 + 5.2*10 2 * 3.14159 * 50 * 1e-4 * 10 + 5.2 * 10

And I would rather avoid doing scaling and tricks "by hand". 我宁愿避免“手动”进行缩放和技巧。

There is nothing readily available for the general purpose processors, but there is a project that claims having variable precision fixed point: https://versaweb.dl.sourceforge.net/project/fixedptc/fixedptc.h . 通用处理器没有现成的可用产品,但是有一个项目声称具有可变精度的固定点: https : //versaweb.dl.sourceforge.net/project/fixedptc/fixedptc.h

For PIC micro there are some libraries that deal with 8-bit size different Q arithmetic as described here: http://ww1.microchip.com/downloads/en/AppNotes/00617.pdf Also, you may see this for more generic description of the problem. 对于PIC micro,有一些库可以处理8位大小不同的Q算术,如此处所述: http : //ww1.microchip.com/downloads/en/AppNotes/00617.pdf另外,您可能会看到它以获得更通用的描述问题。 http://www.superkits.net/whitepapers/Fixed%20Point%20Representation%20&%20Fractional%20Math.pdf Is there a need to write such a library it could be written if needed, with some effort. http://www.superkits.net/cn/whitepapers/Fixed%20Point%20Representation%20&%20Fractional%20Math.pdf是否有必要编写这样的库,如果需要,可以进行一些努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM