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

add sine sqrt power

parent 372e47a0
Branches
No related tags found
1 merge request!1add sine sqrt power
*.out
*.exe
#include "fx_s2308_double.h"
#include <math.h>
typedef double fx_s2308;
#define PI 3.1415926535897
#define to_radian(a) (a*(PI/180))
fx_s2308 fx_sine(fx_s2308 a){
double f_a=fx_to_double(a);
f_a=to_radian(f_a);
return double_to_fx(sin(f_a));
}
fx_s2308 fx_sqrt(fx_s2308 a){
double f_a=fx_to_double(a);
return double_to_fx(sqrt(f_a));
}
fx_s2308 fx_pow(fx_s2308 a, double n){
double f_a=fx_to_double(a);
return double_to_fx(pow(f_a,n));
}
......@@ -6,3 +6,8 @@ typedef double fx_s2308;
#define fx_sub(a,b) (a-b)
#define fx_mul(a,b) double_to_fx((fx_to_double(a)*fx_to_double(b)))
#define fx_div(a,b) double_to_fx((fx_to_double(a)/fx_to_double(b)))
fx_s2308 fx_sine(fx_s2308 a);
fx_s2308 fx_sqrt(fx_s2308 a);
fx_s2308 fx_power(fx_s2308 a, double n);
#include <stdio.h>
#include "fx_s2308_double.h"
typedef double fx_s2308;
int main() {
fx_s2308 a = 200;
fx_s2308 b = 100;
fx_s2308 output = fx_mul(a, b);
printf("%lf",output);
printf("%lf\n",output);
printf("===sine test===\n");
double a1=30.0;
fx_s2308 f_a1=double_to_fx(a1);
fx_s2308 sine_a1=fx_sine(f_a1);
printf("%lf %lf %lf\n",a1,f_a1,fx_to_double(sine_a1));
printf("===sqrt test===\n");
double a2=100.0;
fx_s2308 f_a2=double_to_fx(a2);
fx_s2308 sqrt_a2=fx_sqrt(f_a2);
printf("%lf %lf %lf\n",a2,f_a2,fx_to_double(sqrt_a2));
printf("===power test===\n");
double a3=64.0;
fx_s2308 f_a3=double_to_fx(a3);
fx_s2308 pow_a3=fx_pow(f_a3,2.0);
printf("%lf %lf %lf\n",a3,f_a3,fx_to_double(pow_a3));
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment