Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fx_s4716
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_6
fx_s4716
Commits
c3d35bdc
Commit
c3d35bdc
authored
4 years ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
updated test.c
parent
24c62c31
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
a.out
+0
-0
0 additions, 0 deletions
a.out
fx_s4716_double.c
+2
-2
2 additions, 2 deletions
fx_s4716_double.c
fx_s4716_longlong.c
+13
-13
13 additions, 13 deletions
fx_s4716_longlong.c
fx_s4716_longlong.h
+8
-6
8 additions, 6 deletions
fx_s4716_longlong.h
test.c
+41
-30
41 additions, 30 deletions
test.c
with
64 additions
and
51 deletions
a.out
+
0
−
0
View file @
c3d35bdc
No preview for this file type
This diff is collapsed.
Click to expand it.
fx_s4716_double.c
+
2
−
2
View file @
c3d35bdc
...
...
@@ -18,11 +18,11 @@ void fx_sub(fx_s4716 a, fx_s4716 b){
}
void
fx_mul
(
fx_s4716
a
,
fx_s4716
b
){
double
mul
=
FX_S4716_DOUBLE_MUL
(
a
,
b
);
printf
(
"fx mul : %.16lf
\n
"
,
mul
);
printf
(
"fx mul : %.16lf
\n
"
,
DOUBLE_TO_FX
(
mul
)
)
;
}
void
fx_div
(
fx_s4716
a
,
fx_s4716
b
){
double
div
=
FX_S4716_DOUBLE_DIV
(
a
,
b
);
printf
(
"fx div : %.16lf
\n
"
,
div
);
printf
(
"fx div : %.16lf
\n
"
,
DOUBLE_TO_FX
(
div
)
)
;
}
void
fx_pi
(){
printf
(
"pi : %.16lf
\n
"
,
FX_PI
);
...
...
This diff is collapsed.
Click to expand it.
fx_s4716_longlong.c
+
13
−
13
View file @
c3d35bdc
...
...
@@ -13,31 +13,31 @@ long long fx_to_longlong(fx_s4716 a){
fx_s4716
longlong_to_fx
(
long
long
a
){
return
a
<<
16
;
}
fx_s4716
fx_s4716_longlong_mul
(
fx_s4716
a
,
fx_s4716
b
){
fx_s4716
fx_s4716_longlong_mul
1
(
fx_s4716
a
,
fx_s4716
b
){
long
long
result
=
FX_S4716_LONGLONG_MUL1
(
a
,
b
);
return
result
;
return
longlong_to_fx
(
result
)
;
}
fx_s4716
fx_s4716_longlong_mul
1
(
fx_s4716
a
,
fx_s4716
b
){
fx_s4716
fx_s4716_longlong_mul
2
(
fx_s4716
a
,
fx_s4716
b
){
long
long
result
=
FX_S4716_LONGLONG_MUL2
(
a
,
b
);
return
result
;
return
longlong_to_fx
(
result
)
;
}
fx_s4716
fx_s4716_longlong_mul
2
(
fx_s4716
a
,
fx_s4716
b
){
fx_s4716
fx_s4716_longlong_mul
3
(
fx_s4716
a
,
fx_s4716
b
){
long
long
result
=
FX_S4716_LONGLONG_MUL3
(
a
,
b
);
return
result
;
return
longlong_to_fx
(
result
)
;
}
fx_s4716
fx_s4716_longlong_div
(
fx_s4716
a
,
fx_s4716
b
){
fx_s4716
fx_s4716_longlong_div
1
(
fx_s4716
a
,
fx_s4716
b
){
long
long
result
=
FX_S4716_LONGLONG_DIV1
(
a
,
b
);
return
result
;
return
fx_to_longlong
(
result
)
;
}
fx_s4716
fx_s4716_longlong_div
1
(
fx_s4716
a
,
fx_s4716
b
){
fx_s4716
fx_s4716_longlong_div
2
(
fx_s4716
a
,
fx_s4716
b
){
long
long
result
=
FX_S4716_LONGLONG_DIV2
(
a
,
b
);
return
result
;
return
fx_to_longlong
(
result
)
;
}
fx_s4716
fx_s4716_longlong_div
2
(
fx_s4716
a
,
fx_s4716
b
){
fx_s4716
fx_s4716_longlong_div
3
(
fx_s4716
a
,
fx_s4716
b
){
long
long
result
=
FX_S4716_LONGLONG_DIV3
(
a
,
b
);
return
result
;
return
fx_to_longlong
(
result
)
;
}
fx_s4716
fx_s4716_longlong_sin
(
fx_s4716
a
){
long
long
result
=
sinTable
[
a
];
return
result
;
return
fx_to_longlong
(
result
)
;
}
This diff is collapsed.
Click to expand it.
fx_s4716_longlong.h
+
8
−
6
View file @
c3d35bdc
#define FX_S4716_LONGLONG_MUL(a, b) (((a) * (b)) >> 16)
#define FX_S4716_LONGLONG_MUL1(a, b) ((a >> 8) * (b >> 8))
#define FX_S4716_LONGLONG_MUL2(a, b) (((a >> 4) * (b >> 4)) >> 8)
typedef
long
long
fx_s4716
;
#define FX_S4716_LONGLONG_DIV(a, b) ((a << 16) / (b))
#define FX_S4716_LONGLONG_DIV1(a, b) (((a << 8) / (b)) << 8)
#define FX_S4716_LONGLONG_DIV2(a, b) (((a << 4) / (b >> 4)) << 8)
#define FX_S4716_LONGLONG_MUL1(a, b) (((a) * (b)) >> 16)
#define FX_S4716_LONGLONG_MUL2(a, b) ((a >> 8) * (b >> 8))
#define FX_S4716_LONGLONG_MUL3(a, b) (((a >> 4) * (b >> 4)) >> 8)
#define FX_S4716_LONGLONG_DIV1(a, b) ((a << 16) / (b))
#define FX_S4716_LONGLONG_DIV2(a, b) (((a << 8) / (b)) << 8)
#define FX_S4716_LONGLONG_DIV3(a, b) (((a << 4) / (b >> 4)) << 8)
This diff is collapsed.
Click to expand it.
test.c
+
41
−
30
View file @
c3d35bdc
...
...
@@ -13,6 +13,16 @@ extern void fx_inv_pi();
extern
void
fx_sqrt
(
fx_s4716
a
);
extern
void
fx_pow
(
fx_s4716
a
);
extern
void
fx_sine
(
fx_s4716
a
);
extern
fx_s4716
longlong_to_fx
(
long
long
a
);
extern
long
long
fx_to_longlong
(
fx_s4716
a
);
extern
fx_s4716
fx_s4716_longlong_mul1
(
fx_s4716
a
,
fx_s4716
b
);
extern
fx_s4716
fx_s4716_longlong_mul2
(
fx_s4716
a
,
fx_s4716
b
);
extern
fx_s4716
fx_s4716_longlong_mul3
(
fx_s4716
a
,
fx_s4716
b
);
extern
fx_s4716
fx_s4716_longlong_div1
(
fx_s4716
a
,
fx_s4716
b
);
extern
fx_s4716
fx_s4716_longlong_div2
(
fx_s4716
a
,
fx_s4716
b
);
extern
fx_s4716
fx_s4716_longlong_div3
(
fx_s4716
a
,
fx_s4716
b
);
extern
fx_s4716
fx_s4716_longlong_sin
(
fx_s4716
a
);
int
main
()
{
...
...
@@ -33,76 +43,76 @@ int main()
else
if
(
option
==
1
)
{
printf
(
" OPTION
\n
"
);
printf
(
"
0
. add
\n
"
);
printf
(
"
1
. subtract
\n
"
);
printf
(
"
2
. multiply
\n
"
);
printf
(
"
3
. divide
\n
"
);
printf
(
"
4
. square root
\n
"
);
printf
(
"
5
. power
\n
"
);
printf
(
"
6
. print PI
\n
"
);
printf
(
"
7
. print inverse PI
\n
"
);
printf
(
"
8
. fix to double
\n
"
);
printf
(
"
9
. double to fix
\n
"
);
printf
(
"1
0
get sine value
\n
"
);
printf
(
"
11
. quit
\n\n
"
);
printf
(
"
1
. add
\n
"
);
printf
(
"
2
. subtract
\n
"
);
printf
(
"
3
. multiply
\n
"
);
printf
(
"
4
. divide
\n
"
);
printf
(
"
5
. square root
\n
"
);
printf
(
"
6
. power
\n
"
);
printf
(
"
7
. print PI
\n
"
);
printf
(
"
8
. print inverse PI
\n
"
);
printf
(
"
9
. fix to double
\n
"
);
printf
(
"
10
. double to fix
\n
"
);
printf
(
"1
1.
get sine value
\n
"
);
printf
(
"
0
. quit
\n\n
"
);
while
(
1
)
{
printf
(
"Type option : "
);
fflush
(
stdout
);
scanf
(
"%d"
,
&
option
);
switch
(
option
)
{
case
0
:
case
1
:
printf
(
"Input two number : "
);
fflush
(
stdout
);
scanf
(
"%lld %lld"
,
&
a
,
&
b
);
fx_add
(
a
,
b
);
break
;
case
1
:
case
2
:
printf
(
"Input two number : "
);
fflush
(
stdout
);
scanf
(
"%lld %lld"
,
&
a
,
&
b
);
fx_sub
(
a
,
b
);
break
;
case
2
:
case
3
:
printf
(
"Input two number : "
);
fflush
(
stdout
);
scanf
(
"%lld %lld"
,
&
a
,
&
b
);
fx_mul
(
a
,
b
);
break
;
case
3
:
case
4
:
printf
(
"Input two number : "
);
fflush
(
stdout
);
scanf
(
"%lld %lld"
,
&
a
,
&
b
);
fx_div
(
a
,
b
);
break
;
case
4
:
case
5
:
printf
(
"Input one number : "
);
fflush
(
stdout
);
scanf
(
"%lld"
,
&
a
);
fx_sqrt
(
a
);
break
;
case
5
:
case
6
:
printf
(
"Input one number : "
);
fflush
(
stdout
);
scanf
(
"%lld"
,
&
a
);
fx_pow
(
a
);
break
;
case
6
:
case
7
:
fx_pi
();
break
;
case
7
:
case
8
:
fx_inv_pi
();
break
;
case
8
:
case
9
:
printf
(
"Input fix number : "
);
fflush
(
stdout
);
scanf
(
"%lld"
,
&
a
);
fx_to_double
(
a
);
break
;
case
9
:
case
10
:
printf
(
"Input double number : "
);
fflush
(
stdout
);
scanf
(
"%lf"
,
&
c
);
double_to_fx
(
c
);
break
;
case
1
0
:
case
1
1
:
printf
(
"Input one number : "
);
fflush
(
stdout
);
scanf
(
"%lld"
,
&
a
);
fx_sine
(
a
);
break
;
case
11
:
case
0
:
quit
=
1
;
default:
break
;
...
...
@@ -131,21 +141,22 @@ int main()
case
1
:
printf
(
"Input two number : "
);
fflush
(
stdout
);
scanf
(
"%lld %lld"
,
&
a
,
&
b
);
t
=
fx_s4716_longlong_mul
(
a
,
b
);
tt
=
fx_s4716_longlong_mul
1
(
a
,
b
);
ttt
=
fx_s4716_longlong_mul
2
(
a
,
b
);
t
=
fx_s4716_longlong_mul
1
(
a
,
b
);
tt
=
fx_s4716_longlong_mul
2
(
a
,
b
);
ttt
=
fx_s4716_longlong_mul
3
(
a
,
b
);
printf
(
"%lld %lld %lld
\n
"
,
t
,
tt
,
ttt
);
break
;
case
2
:
printf
(
"Input two number : "
);
fflush
(
stdout
);
scanf
(
"%lld %lld"
,
&
a
,
&
b
);
t
=
fx_s4716_longlong_div
(
a
,
b
);
tt
=
fx_s4716_longlong_div
1
(
a
,
b
);
ttt
=
fx_s4716_longlong_div
2
(
a
,
b
);
t
=
fx_s4716_longlong_div
1
(
a
,
b
);
tt
=
fx_s4716_longlong_div
2
(
a
,
b
);
ttt
=
fx_s4716_longlong_div
3
(
a
,
b
);
printf
(
"%lld %lld %lld
\n
"
,
t
,
tt
,
ttt
);
break
;
}
}
}
else
{}
}
\ No newline at end of file
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