• 大小: 16.47MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-15
  • 语言: 其他
  • 标签: 查表  sin  

资源简介

查表计算sin值,自己写的小程序,经验证可以精确到小数点后第3位

资源截图

代码片段和文件信息

#include “stdio.h“
#include “math.h“
float tanArray[89] = {
0.0174551      0.0349208      0.0524078      0.0699268      0.0874887      0.105104       0.122785       0.140541       0.158384       0.176327

0.19438        0.212557       0.230868       0.249328       0.267949       0.286745       0.305731       0.32492        0.344328       0.36397

0.383864       0.404026       0.424475       0.445229       0.466308       0.487733       0.509525       0.531709       0.554309       0.57735

0.600861       0.624869       0.649408       0.674509       0.700208       0.726543       0.753554       0.781286       0.809784       0.8391

0.869287       0.900404       0.932515       0.965689       1              1.03553        1.07237        1.11061        1.15037        1.19175

1.2349         1.27994        1.32704        1.37638        1.42815        1.48256        1.53986        1.60033        1.66428        1.73205

1.80405        1.88073        1.96261        2.0503         2.14451        2.24604        2.35585        2.47509        2.60509        2.74748

2.90421        3.07768        3.27085        3.48741        3.73205        4.01078        4.33148        4.70463        5.14455        5.67128

6.31375        7.11537        8.14434        9.51436        11.43          14.3007        19.0811        28.6362        57.2899         
};


unsigned char getangle(double data)
{
unsigned char index = 89;
unsigned char mid = 45;
unsigned char begin = 0;
unsigned char end = 89;
unsigned char right = 0;

if(data>tanArray[88])
{
return 89;
}

if(data {
return 1;
}

while(1)
{
index = ((end - begin)/2)+begin;//第二次循环是23

if(data>tanArray[index])
{
right = 1;
begin = index;
if(data>tanArray[index]&&data {
return (data-tanArray[index])>tanArray[index+1]-data?(index+1):index;
}
}
else
{
right = 0;
end = index;
if(data>tanArray[index-1]&&data {
return (data-tanArray[index-1])>tanArray[index]-data?index:(index-1);
}
}  

if(end-begin<1)
{
return (data-tanArray[begin])>tanArray[end]-data?end:begin;
}
}

}

/////找到一个位置,放下这个数,能够让它即大于前面又小于后面

void main()
{
unsigned char data  =  getangle(0.4);
printf(“%d“data);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      15562  2005-04-27 01:30  atan_tab.c

----------- ---------  ---------- -----  ----

                15562                    1


评论

共有 条评论