Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fx_s1516
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_3
fx_s1516
Commits
c1f7f3bb
Commit
c1f7f3bb
authored
4 years ago
by
이화진
Browse files
Options
Downloads
Patches
Plain Diff
Add div
parent
9d1bf1ce
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
fx_s1516
+1
-0
1 addition, 0 deletions
fx_s1516
fx_s1516_longlong/fx_s1516_longlong.c
+0
-0
0 additions, 0 deletions
fx_s1516_longlong/fx_s1516_longlong.c
fx_s1516_longlong/fx_s1516_longlong.h
+38
-0
38 additions, 0 deletions
fx_s1516_longlong/fx_s1516_longlong.h
with
39 additions
and
0 deletions
fx_s1516
@
2f4b31aa
Subproject commit 2f4b31aab1ff4b7689ebd3278d1d93e8dc9195ac
This diff is collapsed.
Click to expand it.
fx_s1516_longlong.c
→
fx_s1516_longlong/
fx_s1516_longlong.c
+
0
−
0
View file @
c1f7f3bb
File moved
This diff is collapsed.
Click to expand it.
fx_s1516_longlong.h
→
fx_s1516_longlong/
fx_s1516_longlong.h
+
38
−
0
View file @
c1f7f3bb
...
@@ -14,3 +14,25 @@ typedef long long fixed64;
...
@@ -14,3 +14,25 @@ typedef long long fixed64;
// 시프트 연산도 나눠보고
// 시프트 연산도 나눠보고
// for 문도 많이 돌려보고
// for 문도 많이 돌려보고
// 값도 아주 작은 거부터 아주 큰거까지 다 넣어보고
// 값도 아주 작은 거부터 아주 큰거까지 다 넣어보고
#define div0(a, b) (fixed32)(((fixed64)(a) << 16) / (b))
#define div1(a, b) ((((a) << 8) / (b)) << 8)
#define div2(a, b) ((a) / ((b) >> 16))
// 나눗셈 연산 : shift 과정에서 나누는 수가 0이 되어 나눠질 수 있으므로 조심해야 한다.
/* <div0>
* a(나눠지는 수)를 long long으로 캐스팅, 16bit shift 연산 후 b(나누는 수)로 나눔
* long long 캐스팅: int(32bit)인 a를 long long(64bit)로 캐스팅함으로써 속도가 느려지지만 16bit shift 연산을 할 때 데이터의 손실을 줄일 수 있다.
* fx_s1516_longlong은 정수형 사칙연산이므로 a와 b가 비슷한 범위의 숫자이거나 실수형으로 계산했을 때 소수점이 나오는 나눗셈인 경우 오차범위가 커지기 때문에 이것을 방지하고자 미리 a를 16bit shift 시킨 후 b로 나눴다.
<div1>
* long long으로 캐스팅하지 않고 int형으로 나눠줬기 때문에 연산 속도가 빠르다.
* 큰 수일 경우 데이터의 손실이 있을 수 있다.
* Overflow 가능성은 작아진다.
<div2>
* div1과 같이 long long으로 캐스팅하지 않았기 때문에 연산 속도가 빠르다.
* Overflow 발생확률이 높다.
* b(나누는 수)가 작은 수일 경우 데이터의 손실이 크다.
*/
\ 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