Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pcc004
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Nayoung Kim
pcc004
Commits
14cc232c
Commit
14cc232c
authored
3 years ago
by
Nayoung Kim
Browse files
Options
Downloads
Patches
Plain Diff
project
parent
3d1d415d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lec10/gptest.c
+46
-0
46 additions, 0 deletions
lec10/gptest.c
lec10/test.c
+1
-1
1 addition, 1 deletion
lec10/test.c
test/pjtest.c
+4
-0
4 additions, 0 deletions
test/pjtest.c
with
51 additions
and
1 deletion
lec10/gptest.c
0 → 100644
+
46
−
0
View file @
14cc232c
#include
<stdio.h>
// #### #### #### #### . #### #### #### ####
// S 15 . 16
#define FX_Q_NUM 16
#define FX_2_MINUS_16 1.52587890625e-05F
#define FX_2_PLUS_16 (1<<16)
#define FX_S_15_16 11516
#define FX_SYSTEM FX_S_15_16
typedef
int
fixed32
;
fixed32
fromFloat
(
float
fa
)
{
return
(
fixed32
)
(
fa
*
FX_2_PLUS_16
)
;
}
float
toFloat
(
fixed32
xa
)
{
return
((
float
)
(
xa
))
*
FX_2_MINUS_16
;
}
fixed32
fxAdd
(
fixed32
a
,
fixed32
b
)
{
return
fromFloat
((
toFloat
(
a
)
+
toFloat
(
b
)));
}
fixed32
fxAdd2
(
fixed32
a
,
fixed32
b
)
{
return
a
+
b
;
}
int
main
()
{
long
long
i
=
0
;
int
ia
,
ib
,
ic
,
ic2
;
float
fa
;
// fscanf(stdin, "%d %d", &ia, &ib);
for
(
i
=
0
;
i
<
(
long
long
)
256
*
256
*
256
*
256
;
i
+=
(
256
*
256
))
{
ic
=
fxAdd
(
i
,
i
);
ic2
=
fxAdd2
(
i
,
i
);
fprintf
(
stdout
,
"%f + %f : %f , %f diff = %d
\n
"
,
toFloat
(
i
),
toFloat
(
i
),
toFloat
(
ic
),
toFloat
(
ic2
),
ic
-
ic2
);
}
//fprintf(stdout, "%d + %d : %d\n", ia, ib , ic) ;
//fprintf(stdout, "%f + %f : %f\n", toFloat(ia), toFloat(ib), toFloat(ic));
}
This diff is collapsed.
Click to expand it.
lec10/test.c
+
1
−
1
View file @
14cc232c
...
...
@@ -23,7 +23,7 @@ float toFloat_fn(fixed32 xa)
fixed32
fxAdd
(
fixed32
a
,
fixed32
b
)
{
return
fromFloat
((
toF
loat
(
a
)
+
toFloat
(
b
)));
return
(
fixed32
)(
FX_2_PLUS_16
*
((((
f
loat
)
(
a
)
)
*
FX_2_MINUS_16
)
+
(((
float
)
(
b
))
*
FX_2_MINUS_16
)));
}
fixed32
fxAdd2
(
fixed32
a
,
fixed32
b
)
...
...
This diff is collapsed.
Click to expand it.
test/pjtest.c
0 → 100644
+
4
−
0
View file @
14cc232c
#include
<stdio.h>
int
main
(){
printf
(
"%d
\n
"
,
((
1
<<
16
)
|
(
17
<<
8
)
|
(
14
)));
}
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