Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fx_s2308
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
battle_C_5
fx_s2308
Commits
170dcfac
Commit
170dcfac
authored
4 years ago
by
Choi Jinyoung
Browse files
Options
Downloads
Patches
Plain Diff
add sine sqrt power
parent
372e47a0
Branches
Branches containing commit
No related tags found
1 merge request
!1
add sine sqrt power
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
fx_s2308_double.c
+18
-1
18 additions, 1 deletion
fx_s2308_double.c
fx_s2308_double.h
+6
-1
6 additions, 1 deletion
fx_s2308_double.h
test.c
+23
-3
23 additions, 3 deletions
test.c
with
49 additions
and
5 deletions
.gitignore
0 → 100644
+
2
−
0
View file @
170dcfac
*.out
*.exe
This diff is collapsed.
Click to expand it.
fx_s2308_double.c
+
18
−
1
View file @
170dcfac
#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
));
}
This diff is collapsed.
Click to expand it.
fx_s2308_double.h
+
6
−
1
View file @
170dcfac
...
...
@@ -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
);
This diff is collapsed.
Click to expand it.
test.c
+
23
−
3
View file @
170dcfac
#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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment