在8位单片机中的浮点数运算---开方,乘法,除法,反正切
2011-06-03 15:06
651 查看
所用单片机:EM78系列,所用仿真器ICE468。
int 1byte , long 4byte
Bit data type cannot be used as a return value.
Double and float are NOT supported by the EM78 Series C Compiler.
开平方根
int 1byte , long 4byte
Bit data type cannot be used as a return value.
Double and float are NOT supported by the EM78 Series C Compiler.
开平方根
unsigned long sqrt_16(unsigned long M) { unsigned long N; int i; unsigned long tmp, ttp; // 结果、循环计数 if (M == 0) // 被开方数,开方结果也为0 return 0; N = 0; tmp = (M >> 30); // 获取最高位:B[m-1] M <<= 2; if (tmp > 1) // 最高位为1 { N ++; // 结果当前位为1,否则为默认的0 tmp -= N; } for (i=15; i>0; i--) // 求剩余的15位 { N <<= 1; // 左移一位 tmp <<= 2; tmp += (M >> 30); // 假设 ttp = N; ttp = (ttp<<1)+1; M <<= 2; if (tmp >= ttp) // 假设成立 { tmp -= ttp; N ++; } } return N; }
相关文章推荐
- 浮点加法、减法, 乘法、除法运算
- S里做小数的乘法运算出现浮点错误的解决方法
- Vdsp(bf561)中的浮点运算(7):float乘法运算
- Vdsp(bf561)中的浮点运算(13):fract16乘法运算
- 计算机如何实现乘法与除法运算
- 快速浮点开方运算
- 实现整数的乘法、减法和除法运算,只允许使用加号
- c笔试面试 之 不用乘法操作(用逻辑运算)实现两个正整数的除法
- 整数高精度运算的库(加法,减法,乘法,除法,取模)
- (PHP实现)只使用++运算实现加法,减法,乘法,除法
- 快速浮点开方运算
- Java大数模板——加法、减法、乘法、除法、开方、求余
- Vdsp(bf561)中的浮点运算(8):float除法运算
- 程序员面试金典: 9.7位操作 7.4只用加号实现整数的乘法、减法和除法运算
- 移位,逻辑运算实现加法,乘法和除法
- YUV转RGB,无除法,无浮点运算
- 只使用++运算实现加法,减法,乘法,除法PHP实现
- python中如何的快速进行除法、乘法运算
- OPenCV下浮点数除法运算不准确问题
- 基于proteus的51单片机仿真实例十九、用单片机端口演示数据的乘法运算结果