Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
cadc6ad6
Commit
cadc6ad6
authored
14 years ago
by
Sander Mathijs van Veen
Browse files
Options
Downloads
Patches
Plain Diff
Added 'extra precision' (calculating 'e').
parent
2dbfe4db
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
simmod/ass1/.gitignore
+1
-0
1 addition, 0 deletions
simmod/ass1/.gitignore
simmod/ass1/Makefile
+4
-1
4 additions, 1 deletion
simmod/ass1/Makefile
simmod/ass1/extra_precision.c
+19
-0
19 additions, 0 deletions
simmod/ass1/extra_precision.c
with
24 additions
and
1 deletion
simmod/ass1/.gitignore
+
1
−
0
View file @
cadc6ad6
...
...
@@ -4,3 +4,4 @@ fp
float_double
report.pdf
fd*
pr
This diff is collapsed.
Click to expand it.
simmod/ass1/Makefile
+
4
−
1
View file @
cadc6ad6
...
...
@@ -3,7 +3,7 @@ FLAGS=-Wall -Wextra -std=c99 -pedantic -O0 -lm
TYPES
=
float double LD
OPS
=
ADD DIV MULT SQRT
all
:
fp speed report.pdf fd
all
:
fp speed report.pdf fd
pr
%.pdf
:
%.tex
pdflatex
$^
...
...
@@ -19,6 +19,9 @@ speed: speed.c
done
;
touch
$@
pr
:
extra_precision.o
$(
CC
)
$(
FLAGS
)
-o
$@
$^
fp
:
floating_point.o
$(
CC
)
$(
FLAGS
)
-o
$@
$^
...
...
This diff is collapsed.
Click to expand it.
simmod/ass1/extra_precision.c
0 → 100644
+
19
−
0
View file @
cadc6ad6
#include
<stdio.h>
// Calculate 'e' using
// e=1+1/1!+1/2!+1/3!+1/4!+...
// 4! is 4x3x2x1. The series converges rapidly to e.
// That series comes from this series:
// ex=1+x/1!+x2/2!+x3/3!+x4/4!+...
int
fact
(
int
x
)
{
return
x
>
0
?
x
*
fact
(
x
-
1
)
:
1
;
}
int
main
(
void
)
{
printf
(
"fact 8: %d
\n
"
,
fact
(
8
));
float
e
=
1
;
for
(
int
i
=
1
;
i
<
20
;
i
++
)
{
e
+=
1
.
f
/
fact
(
i
);
}
printf
(
"approx. e: %.80f
\n
"
,
e
);
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