From 372e47a0cd5959fcec2b56e9b53e1255a2fc931f Mon Sep 17 00:00:00 2001 From: hansuchan <suchan7311@naver.com> Date: Tue, 4 Aug 2020 18:43:34 +0900 Subject: [PATCH] solved error --- fx_s2308_double.h | 6 +++--- test.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fx_s2308_double.h b/fx_s2308_double.h index cf71463..24d61e0 100644 --- a/fx_s2308_double.h +++ b/fx_s2308_double.h @@ -1,8 +1,8 @@ #pragma once typedef double fx_s2308; #define fx_to_double(a) ((double) a/ (256.0)) -#define double_to_fix(a) ((double) a/ (256.0)) +#define double_to_fx(a) ((int) (a* 256.0)) #define fx_add(a,b) (a+b) #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))) \ No newline at end of file +#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))) \ No newline at end of file diff --git a/test.c b/test.c index 0ae6856..a1b7c25 100644 --- a/test.c +++ b/test.c @@ -5,7 +5,7 @@ typedef double fx_s2308; int main() { fx_s2308 a = 200; fx_s2308 b = 100; - fx_s2308 output = fx_add(a, b); + fx_s2308 output = fx_mul(a, b); printf("%lf",output); return 0; } \ No newline at end of file -- GitLab