Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
5823ee31
Commit
5823ee31
authored
Feb 09, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'Extra precision' to report.
parent
d205c1c6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
10 deletions
+41
-10
simmod/ass1/.gitignore
simmod/ass1/.gitignore
+1
-0
simmod/ass1/Makefile
simmod/ass1/Makefile
+4
-1
simmod/ass1/extra_precision.c
simmod/ass1/extra_precision.c
+4
-9
simmod/ass1/report.tex
simmod/ass1/report.tex
+32
-0
No files found.
simmod/ass1/.gitignore
View file @
5823ee31
...
@@ -9,3 +9,4 @@ report.pdf
...
@@ -9,3 +9,4 @@ report.pdf
fd*
fd*
pr
pr
floating_point.tex
floating_point.tex
extra_precision.tex
simmod/ass1/Makefile
View file @
5823ee31
...
@@ -6,7 +6,10 @@ OPS=ADD DIV MULT SQRT
...
@@ -6,7 +6,10 @@ OPS=ADD DIV MULT SQRT
all
:
fp speed highlight report.pdf sum pr
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
floating_point.tex
:
floating_point.c
pygmentize
-O
style
=
colorful
-o
$@
$^
pygmentize
-O
style
=
colorful
-o
$@
$^
...
...
simmod/ass1/extra_precision.c
View file @
5823ee31
#include <stdio.h>
#include <stdio.h>
// Calculate 'e' using
// Calculate 'e' using e=1+1/1!+1/2!+1/3!+1/4!+...
// e=1+1/1!+1/2!+1/3!+1/4!+...
// 8! is 8x7x6x5x4x3x2x1. The series converges rapidly to e.
// 4! is 4x3x2x1. The series converges rapidly to e.
// That series comes from this series:
int
fact
(
int
x
)
{
return
x
>
0
?
x
*
fact
(
x
-
1
)
:
1
;
}
// 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
)
{
int
main
(
void
)
{
float
last_e
,
e
;
float
last_e
,
e
;
...
...
simmod/ass1/report.tex
View file @
5823ee31
...
@@ -153,6 +153,31 @@ Type & N & Forward & Backward \\
...
@@ -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
{}
\appendix
{}
\section
{
floating
\_
point.c
}
% {{{
\section
{
floating
\_
point.c
}
% {{{
...
@@ -162,5 +187,12 @@ Type & N & Forward & Backward \\
...
@@ -162,5 +187,12 @@ Type & N & Forward & Backward \\
% }}}
% }}}
\section
{
extra
\_
precision.c
}
% {{{
\label
{
sec:extra
_
precision.c
}
\input
{
extra
_
precision
}
% }}}
\end
{
document
}
\end
{
document
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment