Skip to content
Snippets Groups Projects
Commit dae905b6 authored by Choi Jinyoung's avatar Choi Jinyoung
Browse files

update test.c

parent ec7e7ac8
Branches
No related tags found
1 merge request!7update test.c
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#define fx_s2308_l_mul3(a,b) (int)(((a)*(b)) >> 8) #define fx_s2308_l_mul3(a,b) (int)(((a)*(b)) >> 8)
#define fx_s2308_l_mul4(a,b) (int)(((a>>4)*(b>>4))) #define fx_s2308_l_mul4(a,b) (int)(((a>>4)*(b>>4)))
#define fx_s2308_l_div1(a,b) (int)((long long)(a)/(b)) #define fx_s2308_l_div1(a,b) (int)(((long long)(a)/(b))<<8)
#define fx_s2308_l_div2(a,b) (int)((a<<8)/(b)) #define fx_s2308_l_div2(a,b) (int)((a<<8)/(b))
typedef int fx_s2308; typedef int fx_s2308;
......
...@@ -37,7 +37,7 @@ int main() { ...@@ -37,7 +37,7 @@ int main() {
printf("\n======STEP 2: fx_s2308 long long Test=======\n"); printf("\n======STEP 2: fx_s2308 long long Test=======\n");
printf("Please enter two double: "); printf("Please enter two double: ");
getchar(); // getchar();
double da; double da;
double db; double db;
scanf("%lf %lf", &da, &db); scanf("%lf %lf", &da, &db);
...@@ -59,12 +59,17 @@ int main() { ...@@ -59,12 +59,17 @@ int main() {
printf("\n\t====== Division =======\n"); printf("\n\t====== Division =======\n");
fc=fx_s2308_l_div1(fa,fb); fc=fx_s2308_l_div1(fa,fb);
printf("\n\t\tdiv1: Exact answer = %f func result = %f, error = %f\n",da/db, FX_TO_DOUBLE(fc), da/db-FX_TO_DOUBLE(fc)); printf("\n\tdiv1: Exact answer = %f func result = %f, error = %f\n",da/db, FX_TO_DOUBLE(fc), da/db-FX_TO_DOUBLE(fc));
fc=fx_s2308_l_div2(fa,fb); fc=fx_s2308_l_div2(fa,fb);
printf("\n\tdiv2: Exact answer = %f func result = %f, error = %f\n",da/db, FX_TO_DOUBLE(fc), da/db-FX_TO_DOUBLE(fc)); printf("\n\tdiv2: Exact answer = %f func result = %f, error = %f\n",da/db, FX_TO_DOUBLE(fc), da/db-FX_TO_DOUBLE(fc));
printf("\n\t====== Sine =======\n"); printf("\n\t====== Sine =======\n");
printf("\n\t fx_s2308 long long sine 30 = %lf", FX_TO_DOUBLE(fx_s2308_sind(DOUBLE_TO_FX(30)))); printf("\n\t fx_s2308 long long sine 30 = %lf\n", FX_TO_DOUBLE(fx_s2308_sind(DOUBLE_TO_FX(30))));
printf("\n\t fx_s2308 long long sine -30 = %lf\n", FX_TO_DOUBLE(fx_s2308_sind(DOUBLE_TO_FX(-30))));
printf("\n\t fx_s2308 long long sine 190 = %lf\n", FX_TO_DOUBLE(fx_s2308_sind(DOUBLE_TO_FX(210))));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment