打印

请教ARM中Q格式函数

[复制链接]
2135|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Periodic|  楼主 | 2012-1-31 17:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
//*****************************************************************************
//
// Simple multiplies or divides, which are accomplished with simple shifts.
//
//*****************************************************************************
#define _IQmpy2(A)              ((A) << 1)
#define _IQmpy4(A)              ((A) << 2)
#define _IQmpy8(A)              ((A) << 3)
#define _IQmpy16(A)             ((A) << 4)
#define _IQmpy32(A)             ((A) << 5)
#define _IQmpy64(A)             ((A) << 6)
#define _IQdiv2(A)              ((A) >> 1)
#define _IQdiv4(A)              ((A) >> 2)
#define _IQdiv8(A)              ((A) >> 3)
#define _IQdiv16(A)             ((A) >> 4)
#define _IQdiv32(A)             ((A) >> 5)
#define _IQdiv64(A)             ((A) >> 6)
//*****************************************************************************
//
// Convert a value into an IQ number.
//
//*****************************************************************************
#define _IQ30(A)                ((_iq30)((A) * (1 << 30)))
#define _IQ29(A)                ((_iq29)((A) * (1 << 29)))
#define _IQ28(A)                ((_iq28)((A) * (1 << 28)))
#define _IQ27(A)                ((_iq27)((A) * (1 << 27)))
#define _IQ26(A)                ((_iq26)((A) * (1 << 26)))
#define _IQ25(A)                ((_iq25)((A) * (1 << 25)))
#define _IQ24(A)                ((_iq24)((A) * (1 << 24)))
#define _IQ23(A)                ((_iq23)((A) * (1 << 23)))
#define _IQ22(A)                ((_iq22)((A) * (1 << 22)))
#define _IQ21(A)                ((_iq21)((A) * (1 << 21)))
#define _IQ20(A)                ((_iq20)((A) * (1 << 20)))
#define _IQ19(A)                ((_iq19)((A) * (1 << 19)))
#define _IQ18(A)                ((_iq18)((A) * (1 << 18)))
#define _IQ17(A)                ((_iq17)((A) * (1 << 17)))
#define _IQ16(A)                ((_iq16)((A) * (1 << 16)))
#define _IQ15(A)                ((_iq15)((A) * (1 << 15)))
#define _IQ14(A)                ((_iq14)((A) * (1 << 14)))
#define _IQ13(A)                ((_iq13)((A) * (1 << 13)))
#define _IQ12(A)                ((_iq12)((A) * (1 << 12)))
#define _IQ11(A)                ((_iq11)((A) * (1 << 11)))
#define _IQ10(A)                ((_iq10)((A) * (1 << 10)))
#define _IQ9(A)                 ((_iq9)((A) * (1 << 9)))
#define _IQ8(A)                 ((_iq8)((A) * (1 << 8)))
#define _IQ7(A)                 ((_iq7)((A) * (1 << 7)))
#define _IQ6(A)                 ((_iq6)((A) * (1 << 6)))
#define _IQ5(A)                 ((_iq5)((A) * (1 << 5)))
#define _IQ4(A)                 ((_iq4)((A) * (1 << 4)))
#define _IQ3(A)                 ((_iq3)((A) * (1 << 3)))
#define _IQ2(A)                 ((_iq2)((A) * (1 << 2)))
#define _IQ1(A)                 ((_iq1)((A) * (1 << 1)))

相关帖子

沙发
Periodic|  楼主 | 2012-1-31 17:10 | 只看该作者
#define _IQ15(A)                ((_iq15)((A) * (1 << 15)))


请教_IQ15(1.3)=?

使用特权

评论回复
板凳
Periodic|  楼主 | 2012-1-31 17:11 | 只看该作者
是不是 1.3*32768=42598.4

使用特权

评论回复
地板
mybao| | 2012-2-1 10:41 | 只看该作者
取整就对了

使用特权

评论回复
5
石摊摊| | 2013-12-6 20:12 | 只看该作者
这些#define是在那个头文件里面啊?

使用特权

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

本版积分规则

1

主题

670

帖子

2

粉丝