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

change test.c for step1

parent 17193acd
Branches
No related tags found
1 merge request!6Long2
#include <stdio.h> #include <stdio.h>
#include <math.h>
#include "fx_s2308_double.h" #include "fx_s2308_double.h"
#include "fx_s2308_longlong.h" #include "fx_s2308_longlong.h"
int main() { int main() {
fx_s2308 a = 2000;
fx_s2308 b = 1000;
printf("\n===Calculation: Addition===\n");
printf("%d + %d = %d\n",a,b,FX_ADD(a,b));
printf("\n===Calculation: Subtraction===\n");
printf("%d - %d = %d\n",a,b,FX_SUB(a,b));
printf("\n===Calculation: Multiplication===\n");
printf("%d * %d = %d\n",a,b,FX_MUL(a,b));
printf("\n===Calculation: Division===\n");
printf("%d / %d = %d\n",a,b,FX_DIV(a,b));
printf("\n===Function: Sine===\n");
double a1=30.0;
fx_s2308 f_a1=DOUBLE_TO_FX(a1);
fx_s2308 sine_a1=fx_s2308_double_sine(f_a1);
printf("sine(%f)의 fx_2308 값: %d, Double로 변환: %lf\n",a1,f_a1,FX_TO_DOUBLE(sine_a1));
printf("\n===Function: Sqrt===\n");
double a2=100.0;
fx_s2308 f_a2=DOUBLE_TO_FX(a2);
fx_s2308 sqrt_a2=fx_s2308_double_sqrt(f_a2);
printf("sqrt(%f)의 fx_2308 값: %d Double로 변환: %lf\n",a2,f_a2,FX_TO_DOUBLE(sqrt_a2));
printf("\n===Function: Power===\n");
double a3=64.0;
fx_s2308 f_a3=DOUBLE_TO_FX(a3);
fx_s2308 pow_a3=fx_s2308_double_pow(f_a3,2.0);
printf("%f의 2.0 제곱의 fx_2308 값: %d, Double로 변환: %lf\n",a3,f_a3,FX_TO_DOUBLE(pow_a3));
printf("\n===Conversion: fx to double===\n");
printf("fx_s2308 %d is changed into double %lf\n", a, FX_TO_DOUBLE(a));
printf("\n===Conversion: fx to float===\n");
printf("fx_s2308 %d is changed into float %f\n", a, FX_TO_FLOAT(a));
printf("\n===Conversion: fx to int===\n");
printf("fx_s2308 %d is changed into double %d\n", a, FX_TO_INT(a));
printf("\n===Conversion: fx to short===\n");
printf("fx_s2308 %d is changed into double %d\n", a, FX_TO_SHORT(a));
printf("\n===Constant: PI===\n");
printf("PI의 fx_2308 값: %d\n",FX_PI);
printf("\n===Constant: Inverse PI===\n");
printf("1/PI의 fx_2308 값: %d\n",FX_INV_PI);
double a,b;
fx_s2308 f_a,f_b;
printf("\n======STEP 1: fx_s2308 double Test=======\n");
printf("Please enter two double number: ");
scanf("%lf %lf", &a, &b);
f_a=DOUBLE_TO_FX(a);
f_b=DOUBLE_TO_FX(b);
printf("\n====== Calculation =======\n");
printf("\t 1. Add: Exact answer: %lf, Fixed Point Result: %lf\n", a+b, FX_TO_DOUBLE(FX_ADD(f_a,f_b)));
printf("\t 2. Subtraction: Exact answer: %lf, Fixed Point Result: %lf\n", a-b, FX_TO_DOUBLE(FX_SUB(f_a,f_b)));
printf("\t 3. Multiplication: Exact answer: %lf, Fixed Point Result: %lf\n", a*b, FX_TO_DOUBLE(FX_MUL(f_a,f_b)));
printf("\t 4. Division: Exact answer: %lf, Fixed Point Result: %lf\n", a/b, FX_TO_DOUBLE(FX_DIV(f_a,f_b)));
printf("\n====== Function =======\n");
printf("\t 1. Sine(%lf): Exact answer: %lf, Fixed Point Result: %lf\n", a, sin(a*(PI/180)), FX_TO_DOUBLE(fx_s2308_double_sine(f_a)));
printf("\t 2. Sqrt(%lf): Exact answer: %lf, Fixed Point Result: %lf\n", a, sqrt(a), FX_TO_DOUBLE(fx_s2308_double_sqrt(f_a)));
printf("\t 3. Power(%lf,2): Exact answer: %lf, Fixed Point Result: %lf\n", a, pow(a,2), FX_TO_DOUBLE(fx_s2308_double_pow(f_a,2)));
printf("\n====== Conversion =======\n");
printf("\t 1. Fx to Double: fx_s2308 %d is changed into double %lf\n", f_a, FX_TO_DOUBLE(f_a));
printf("\t 2. Fx to Float: fx_s2308 %d is changed into float %f\n", f_a, FX_TO_FLOAT(f_a));
printf("\t 3. Fx to Int: fx_s2308 %d is changed into int %d\n", f_a, FX_TO_INT(f_a));
printf("\t 4. Fx to Short: fx_s2308 %d is changed into short %hd\n", f_a, FX_TO_SHORT(f_a));
printf("\n====== Constant =======\n");
printf("\t 1. PI: PI to fx_2308: %d\n",FX_PI);
printf("\t 2. 1/PI: 1/PI to fx_2308: %d\n",FX_INV_PI);
printf("\n======STEP 2: fx_s2308 long long Test=======\n");
printf("Please enter two double: ");
getchar();
double da; double da;
double db; double db;
scanf("%lf %lf", &da, &db); scanf("%lf %lf", &da, &db);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment