#1楼主:GCC库中两定点乘除函数编译出错
文章发表于:2008-09-27 02:51
GCC库中两定点乘除函数编译出错
如下两函数均是从网上的GCC定点函数库中抽取出来的,此两函数返回类型和实参变量均是定点数格式。我使用的定点数为无符号32位(整数部分和小数部分各占16位),即16位.16位格式。但我在使用中均发现出错,且又没想到怎么去修改成功,望达人看过后指正一二,谢谢!
#define FixedPtBits 16
unsigned long fixedptMultiply(unsigned long a, unsigned long b)
{
// multiply a and b (a*b) with fixed-point math
return (a*b)>>FixedPtBits;
}
unsigned long fixedptDivide(unsigned long numer, unsigned long denom)
{
// divide numer by denom (numer/denom) with fixed-point math
return (numer<<FixedPtBits)/denom;
}