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
5823ee31
Commit
5823ee31
authored
14 years ago
by
Sander Mathijs van Veen
Browse files
Options
Downloads
Patches
Plain Diff
Added 'Extra precision' to report.
parent
d205c1c6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 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
+4
-9
4 additions, 9 deletions
simmod/ass1/extra_precision.c
simmod/ass1/report.tex
+32
-0
32 additions, 0 deletions
simmod/ass1/report.tex
with
41 additions
and
10 deletions
simmod/ass1/.gitignore
+
1
−
0
View file @
5823ee31
...
...
@@ -9,3 +9,4 @@ report.pdf
fd*
pr
floating_point.tex
extra_precision.tex
This diff is collapsed.
Click to expand it.
simmod/ass1/Makefile
+
4
−
1
View file @
5823ee31
...
...
@@ -6,7 +6,10 @@ OPS=ADD DIV MULT SQRT
all
:
fp speed highlight report.pdf sum pr
highlight
:
floating_point.tex
highlight
:
floating_point.tex extra_precision.tex
extra_precision.tex
:
extra_precision.c
pygmentize
-O
style
=
colorful
-o
$@
$^
floating_point.tex
:
floating_point.c
pygmentize
-O
style
=
colorful
-o
$@
$^
...
...
This diff is collapsed.
Click to expand it.
simmod/ass1/extra_precision.c
+
4
−
9
View file @
5823ee31
#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
;
}
// Calculate 'e' using e=1+1/1!+1/2!+1/3!+1/4!+...
// 8! is 8x7x6x5x4x3x2x1. The series converges rapidly to e.
int
fact
(
int
x
)
{
return
x
>
0
?
x
*
fact
(
x
-
1
)
:
1
;
}
int
main
(
void
)
{
float
last_e
,
e
;
...
...
This diff is collapsed.
Click to expand it.
simmod/ass1/report.tex
+
32
−
0
View file @
5823ee31
...
...
@@ -153,6 +153,31 @@ Type & N & Forward & Backward \\
% }}}
\section
{
Extra precision
}
% {{{
\label
{
sec:Extra precision
}
Our machine has an Intel Core2 Duo cpu (cpu type is E6750) running at 2.66GHz.
Because Intel added the x87 instruction set (a subset of x86), the FPU
(floating point unit) has a more precise floating point register.
To demonstrate this, we created simple C program, which will approximate the
constant
$
e
$
twice. The first time it will save the final result in a float, the
second time it will store the result in the floating point register. The second
approximation is compared to the first and if the first approximation is large
than the second, the processor has a more precise floating point register. The
simple C program is listed in the appendix
\ref
{
sec:extra
_
precision.c
}
and
produces this output:
\begin{verbatim}
$
.
/
pr
more precision detected
!
diff:
2
.
6910297870635986328125000000000000000000000000000000000
2
.
6910298253667153112189680541632696986198425292968750000
\end
{
verbatim
}
% }}}
\appendix
{}
\section
{
floating
\_
point.c
}
% {{{
...
...
@@ -162,5 +187,12 @@ Type & N & Forward & Backward \\
% }}}
\section
{
extra
\_
precision.c
}
% {{{
\label
{
sec:extra
_
precision.c
}
\input
{
extra
_
precision
}
% }}}
\end
{
document
}
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