在8位单片机中的浮点数运算开方,乘法,除法,反正切
时间:11-20
来源:互联网
点击:
所用单片机: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.
开平方根
- unsignedlongsqrt_16(unsignedlongM)
- {
- unsignedlongN;
- inti;
- unsignedlongtmp,ttp;//结果、循环计数
- if(M==0)//被开方数,开方结果也为0
- return0;
- 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++;
- }
- }
- returnN;
- }
8位单片机浮点数运 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)