打印

请用数学原理证明下面的Q格式乘法和除法的舍入

[复制链接]
2420|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
snakeemail|  楼主 | 2010-1-26 23:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
TI, COM, ecom, ic, IO
Multiplication
// precomputed value:
#define K   (1 << (Q-1))

signed int       a, b, result;
signed long int  temp;
temp = (long int) a * (long int) b; // result type is operand's type
// Rounding; mid values are rounded up
temp += K;
// Correct by dividing by base
result= temp >> Q;
[edit]
Division
signed int a,b,result;
signed long int temp;
// pre-multiply by the base
temp = (long int)a << Q;
// So the result will be rounded ; mid values are rounded up.
temp = temp+b/2;
result = temp/b;

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:提供500W线性 交流电源。0~300VAC,45~500Hz 提供10KW,0-330V直流电源,具体见http://blog.21ic.com/user1/3639/archives/2012/88528.html

547

主题

1910

帖子

8

粉丝