⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 是codic算法实现Sin的浮点C程序
💻 C
字号:

#include "headDefine.h"

void main() {
	
	// LONG_PI        2147483648
	int i;
	long tTheta;// = 290540485;
	double theat6[721] = {0};
	double theat5[721] = {0};
	double theat4[721] = {0};
	double theat3[721] = {0};
	double theat2[721] = {0};
	double thetaSum = 0;
	double thetaError = 0;
	double thetaSum1 = 0;
	double thetaError1 = 0;
	//int theta3;
	
	//double theta4 = sinCordic(tTheta / pow(2, 31) * PI);
	//double theta5 = sin(tTheta / pow(2, 31) * PI);
	
	//int theta1 = theta5 * 256;
	//int theta2 = intSinCordic(tTheta);

	// LONG_PI           2147483648				    2147483648  11930465->1度
	for (i = 0, tTheta = 0; i < 720; tTheta = tTheta + 11930465, i++) {
		/*if (i == 70){
			i = i;
		}*/
		theat5[i] = sin(tTheta / pow(2, 31) * PI) * 256 * 1.0 ;
		theat3[i] = intSin(tTheta);
		theat4[i] = intSinCordic(tTheta);
		//if (theat4[i] != 0) {
			theat6[i] = theat5[i] - theat4[i];
			theat2[i] = theat5[i] - theat3[i];
		//}
		//else theat6[i] = 0;
	}
	
	/*for (i = 71; i < 90; i++) {
		thetaSum = thetaSum + theat6[i];
		//thetaSum1 = thetaSum1 + theat2[i];
	}
	thetaSum = (thetaSum - 1) / 19; */

	for (i = 0; i <720; i++) {
		if (fabs(theat6[i]) > thetaError) {
			thetaError = fabs(theat6[i]);
		}
		if (fabs(theat2[i]) > thetaError1) {
			thetaError1 = fabs(theat2[i]);
		}
	}
	//etaError = thetaError / 256;

	//thetaSum = (thetaSum - 14) / (360 - 16); //

	i = 0;
	// get the max error of sinCordic
	/*double theta;
	int i = 0;
	double thetaError1[310] = {0};
	double thetaError2[310] = {0};
	double thetaError3[310] = {0};
	double maxError = 0;
	
	i = sizeof(long double);
	for (theta = 0; theta < 300; theta = theta + 1, i++) {
		thetaError2[i] = sinCordic(theta);
		thetaError3[i] = sin(theta);
		thetaError1[i] = thetaError2[i] - thetaError3[i];
		if (fabs(thetaError1[i]) >= maxError) {
			maxError = fabs(thetaError1[i]);
		}
	}
	
	for(i = 0; i < 300; i++) {
		if (fabs(thetaError1[i]) > 0.01) {
			printf("thetaError1[%d] = %f\n\n", i, thetaError1[i]);
		}
	}
	printf("maxError = %f\n", maxError);*/
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -