<s>
As	O
with	O
other	O
spreadsheets	O
,	O
Microsoft	B-Application
Excel	I-Application
works	O
only	O
to	O
limited	O
accuracy	O
because	O
it	O
retains	O
only	O
a	O
certain	O
number	O
of	O
figures	O
to	O
describe	O
numbers	O
(	O
it	O
has	O
limited	O
precision	B-Architecture
)	O
.	O
</s>
<s>
With	O
some	O
exceptions	O
regarding	O
erroneous	O
values	O
,	O
infinities	O
,	O
and	O
denormalized	O
numbers	O
,	O
Excel	B-Application
calculates	O
in	O
double-precision	O
floating-point	O
format	O
from	O
the	O
IEEE	O
754	O
specification	O
(	O
besides	O
numbers	O
,	O
Excel	B-Application
uses	O
a	O
few	O
other	O
data	O
types	O
)	O
.	O
</s>
<s>
Although	O
Excel	B-Application
allows	O
display	O
of	O
up	O
to	O
30decimal	O
places	O
,	O
its	O
precision	B-Architecture
for	O
any	O
specific	O
number	O
is	O
no	O
more	O
than	O
15significant	O
figures	O
,	O
and	O
calculations	O
may	O
have	O
an	O
accuracy	O
that	O
is	O
even	O
less	O
due	O
to	O
five	O
issues	O
:	O
round	B-Algorithm
off	I-Algorithm
,	O
</s>
<s>
truncation	B-Algorithm
,	O
and	O
binary	O
storage	O
,	O
accumulation	O
of	O
the	O
deviations	O
of	O
the	O
operands	O
in	O
calculations	O
,	O
and	O
worst	O
:	O
cancellation	O
at	O
subtractions	O
resp	O
.	O
</s>
<s>
In	O
the	O
top	O
figure	O
the	O
fraction	O
1/9000	O
in	O
Excel	B-Application
is	O
displayed	O
.	O
</s>
<s>
Although	O
this	O
number	O
has	O
a	O
decimal	O
representation	O
that	O
is	O
an	O
infinite	O
string	O
of	O
ones	O
,	O
Excel	B-Application
displays	O
only	O
the	O
leading	O
15	O
figures	O
.	O
</s>
<s>
In	O
the	O
second	O
line	O
,	O
the	O
number	O
one	O
is	O
added	O
to	O
the	O
fraction	O
,	O
and	O
again	O
Excel	B-Application
displays	O
only	O
15	O
figures	O
.	O
</s>
<s>
In	O
the	O
third	O
line	O
,	O
one	O
is	O
subtracted	O
from	O
the	O
sum	O
using	O
Excel	B-Application
.	O
</s>
<s>
However	O
,	O
the	O
difference	O
reported	O
by	O
Excel	B-Application
is	O
three	O
0s	O
followed	O
by	O
a	O
15digit	O
string	O
of	O
thirteen	O
1s	O
and	O
two	O
extra	O
erroneous	O
digits	O
.	O
</s>
<s>
Thus	O
,	O
the	O
numbers	O
Excel	B-Application
calculates	O
with	O
are	O
not	O
the	O
numbers	O
that	O
it	O
displays	O
.	O
</s>
<s>
Moreover	O
,	O
the	O
error	O
in	O
Excel	B-Application
's	O
answer	O
is	O
not	O
simply	O
round-off	B-Algorithm
error	I-Algorithm
,	O
it	O
is	O
an	O
effect	O
in	O
floating	O
point	O
calculations	O
called	O
'	O
cancellation	O
 '	O
.	O
</s>
<s>
The	O
inaccuracy	O
in	O
Excel	B-Application
calculations	O
is	O
more	O
complicated	O
than	O
errors	O
due	O
to	O
a	O
precision	B-Architecture
of	O
15	O
significant	B-Architecture
figures	I-Architecture
.	O
</s>
<s>
Excel	B-Application
's	O
storage	O
of	O
numbers	O
in	O
binary	O
format	O
also	O
affects	O
its	O
accuracy	O
.	O
</s>
<s>
All	O
the	O
values	O
of	O
begin	O
at	O
the	O
15th	O
decimal	O
,	O
so	O
Excel	B-Application
must	O
take	O
them	O
into	O
account	O
.	O
</s>
<s>
Before	O
calculating	O
the	O
sum	O
Excel	B-Application
first	O
approximates	O
as	O
a	O
binary	O
number	O
.	O
</s>
<s>
Here	O
the	O
'	O
IEEE754	O
double	O
value	O
 '	O
resulting	O
of	O
the	O
15bit	O
figure	O
is	O
3.330560653658221E-15	O
,	O
which	O
is	O
rounded	O
by	O
Excel	B-Application
for	O
the	O
'	O
user	O
interface	O
 '	O
to	O
15digits	O
3.33056065365822E-15	O
,	O
and	O
then	O
displayed	O
with	O
30decimals	O
digits	O
gets	O
one	O
'	O
fake	O
zero	O
 '	O
added	O
,	O
thus	O
the	O
'	O
binary	O
 '	O
and	O
'	O
decimal	O
 '	O
values	O
in	O
the	O
sample	O
are	O
identical	O
only	O
in	O
display	O
,	O
the	O
values	O
associated	O
with	O
the	O
cells	O
are	O
different	O
(	O
1.1101111111111100000000000000000000000000000000000000	O
×	O
2−49	O
vs.	O
1.1101111111111011111111111111111111111111111111111101	O
×	O
2−49	O
)	O
.	O
</s>
<s>
In	O
the	O
fourth	O
example	O
,	O
is	O
a	O
decimal	O
number	O
not	O
equivalent	O
to	O
a	O
simple	O
binary	O
(	O
although	O
it	O
agrees	O
with	O
the	O
binary	O
of	O
the	O
third	O
example	O
to	O
the	O
precision	B-Architecture
displayed	O
)	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
then	O
an	O
error	O
in	O
the	O
13th	O
significant	B-Architecture
figure	I-Architecture
.	O
</s>
<s>
In	O
this	O
case	O
,	O
if	O
Excel	B-Application
simply	O
added	O
and	O
subtracted	O
the	O
decimal	O
numbers	O
,	O
avoiding	O
the	O
conversion	O
to	O
binary	O
and	O
back	O
again	O
to	O
decimal	O
,	O
no	O
round-off	B-Algorithm
error	I-Algorithm
would	O
occur	O
and	O
accuracy	O
actually	O
would	O
be	O
better	O
.	O
</s>
<s>
Excel	B-Application
has	O
the	O
option	O
to	O
"	O
Set	O
precision	B-Architecture
as	O
displayed	O
"	O
.	O
</s>
<s>
With	O
this	O
option	O
,	O
depending	O
upon	O
circumstance	O
,	O
accuracy	O
may	O
turn	O
out	O
to	O
be	O
better	O
or	O
worse	O
,	O
but	O
you	O
will	O
know	O
exactly	O
what	O
Excel	B-Application
is	O
doing	O
.	O
</s>
<s>
(	O
Only	O
the	O
selected	O
precision	B-Architecture
is	O
retained	O
,	O
and	O
one	O
cannot	O
recover	O
extra	O
digits	O
by	O
reversing	O
this	O
option	O
.	O
)	O
</s>
<s>
In	O
short	O
,	O
a	O
variety	O
of	O
accuracy	O
behavior	O
is	O
introduced	O
by	O
the	O
combination	O
of	O
representing	O
a	O
number	O
with	O
a	O
limited	O
number	O
of	O
binary	O
digits	O
,	O
along	O
with	O
truncating	B-Algorithm
numbers	O
beyond	O
the	O
fifteenth	O
significant	B-Architecture
figure	I-Architecture
.	O
</s>
<s>
Excel	B-Application
's	O
treatment	O
of	O
numbers	O
beyond	O
15	O
significant	B-Architecture
figures	I-Architecture
sometimes	O
contributes	O
better	O
accuracy	O
to	O
the	O
final	O
few	O
significant	B-Architecture
figures	I-Architecture
of	O
a	O
computation	O
than	O
working	O
directly	O
with	O
only	O
15	O
significant	B-Architecture
figures	I-Architecture
,	O
and	O
sometimes	O
not	O
.	O
</s>
<s>
For	O
the	O
reasoning	O
behind	O
the	O
conversion	O
to	O
binary	O
representation	O
and	O
back	O
to	O
decimal	O
,	O
and	O
for	O
more	O
detail	O
about	O
accuracy	O
in	O
Excel	B-Application
and	O
VBA	B-Language
consult	O
these	O
links	O
.	O
</s>
<s>
The	O
shortcomings	O
in	O
the	O
tasks	O
are	O
a	O
combination	O
of	O
'	O
fp-math	O
weaknesses	O
 '	O
and	O
'	O
how	O
Excel	B-Application
handles	O
it	O
 '	O
,	O
especially	O
Excel	B-Application
's	O
rounding	O
.	O
</s>
<s>
Excel	B-Application
does	O
some	O
rounding	O
and	O
/	O
or	O
'	O
snap	O
to	O
zero	O
 '	O
for	O
most	O
of	O
its	O
results	O
,	O
in	O
average	O
chopping	O
the	O
last	O
3bits	O
of	O
the	O
IEEE	O
double	O
representation	O
.	O
</s>
<s>
As	O
most	O
decimal	O
values	O
do	O
not	O
have	O
a	O
clean	O
finite	O
representation	O
in	O
binary	O
they	O
will	O
suffer	O
from	O
'	O
round	B-Algorithm
off	I-Algorithm
 '	O
and	O
'	O
cancellation	O
 '	O
in	O
tasks	O
like	O
the	O
above	O
.	O
</s>
<s>
Thus	O
from	O
'	O
=	O
(	O
140737488355328.0	O
+	O
0.1	O
-	O
140737488355328.0	O
)	O
it	O
will	O
come	O
back	O
as	O
0.09375	O
instead	O
of	O
0.1	O
when	O
calculated	O
with	O
www.weitz.de/ieee	O
(	O
64bit	O
)	O
as	O
well	O
as	O
in	O
Excel	B-Application
with	O
the	O
parentheses	O
around	O
the	O
formula	O
.	O
</s>
<s>
This	O
effect	O
mostly	O
can	O
be	O
managed	O
by	O
meaningful	O
rounding	O
,	O
which	O
Excel	B-Application
does	O
not	O
apply	O
:	O
It	O
is	O
up	O
to	O
the	O
user	O
.	O
</s>
<s>
Needless	O
to	O
say	O
,	O
other	O
spreadsheets	O
have	O
similar	O
problems	O
,	O
LibreOffice	O
Calc	O
uses	O
a	O
more	O
aggressive	O
rounding	O
,	O
while	O
gnumeric	O
tries	O
to	O
keep	O
precision	B-Architecture
and	O
make	O
as	O
well	O
the	O
precision	B-Architecture
as	O
the	O
'	O
lack	O
of	O
 '	O
visible	O
for	O
the	O
user	O
.	O
</s>
<s>
Accuracy	O
in	O
Excel-provided	O
functions	O
can	O
be	O
an	O
issue	O
.	O
</s>
<s>
However	O
,	O
the	O
first	O
form	O
keeps	O
better	O
numerical	O
accuracy	O
for	O
large	O
values	O
of	O
,	O
because	O
squares	O
of	O
differences	O
between	O
and	O
leads	O
to	O
less	O
round-off	B-Algorithm
than	O
the	O
differences	O
between	O
the	O
much	O
larger	O
numbers	O
and	O
The	O
built-in	O
Excel	B-Application
function	O
,	O
however	O
,	O
uses	O
the	O
less	O
accurate	O
formulation	O
because	O
it	O
is	O
faster	O
computationally	O
.	O
</s>
<s>
For	O
example	O
,	O
on	O
a	O
calculator	O
,	O
if	O
the	O
internal	O
representation	O
of	O
a	O
displayed	O
value	O
is	O
not	O
rounded	O
to	O
the	O
same	O
precision	B-Architecture
as	O
the	O
display	O
,	O
then	O
the	O
result	O
of	O
further	O
operations	O
will	O
depend	O
on	O
the	O
hidden	O
digits	O
and	O
appear	O
unpredictable	O
to	O
the	O
user	O
 '	O
...	O
</s>
<s>
The	O
problem	O
is	O
not	O
limited	O
to	O
Excel	B-Application
,	O
e.g.	O
</s>
<s>
User	O
computations	O
must	O
be	O
carefully	O
organized	O
to	O
ensure	O
round-off	B-Algorithm
error	I-Algorithm
does	O
not	O
become	O
an	O
issue	O
.	O
</s>
<s>
When	O
one	O
of	O
these	O
roots	O
is	O
very	O
large	O
compared	O
to	O
the	O
other	O
,	O
that	O
is	O
,	O
when	O
the	O
square	O
root	O
is	O
close	O
to	O
the	O
value	O
b	O
,	O
the	O
evaluation	O
of	O
the	O
root	O
corresponding	O
to	O
subtraction	O
of	O
the	O
two	O
terms	O
becomes	O
very	O
inaccurate	O
due	O
to	O
round-off	B-Algorithm
(	O
cancellation	O
?	O
</s>
<s>
It	O
is	O
possible	O
to	O
determine	O
the	O
round-off	B-Algorithm
error	I-Algorithm
by	O
using	O
the	O
Taylor	O
series	O
formula	O
for	O
the	O
square	O
root	O
:	O
</s>
<s>
Under	O
these	O
circumstances	O
,	O
all	O
the	O
significant	B-Architecture
figures	I-Architecture
go	O
into	O
expressing	O
b	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
the	O
precision	B-Architecture
is	O
15	O
figures	O
,	O
and	O
these	O
two	O
numbers	O
,	O
b	O
and	O
the	O
square	O
root	O
,	O
are	O
the	O
same	O
to	O
15	O
figures	O
,	O
the	O
difference	O
will	O
be	O
zero	O
instead	O
of	O
the	O
difference	O
ε	O
.	O
</s>
<s>
These	O
results	O
are	O
not	O
subject	O
to	O
round-off	B-Algorithm
error	I-Algorithm
,	O
but	O
they	O
are	O
not	O
accurate	O
unless	O
b2	O
is	O
large	O
compared	O
to	O
ac	O
.	O
</s>
<s>
The	O
bottom	O
line	O
is	O
that	O
in	O
doing	O
this	O
calculation	O
using	O
Excel	B-Application
,	O
as	O
the	O
roots	O
become	O
farther	O
apart	O
in	O
value	O
,	O
the	O
method	O
of	O
calculation	O
will	O
have	O
to	O
switch	O
from	O
direct	O
evaluation	O
of	O
the	O
quadratic	O
formula	O
to	O
some	O
other	O
method	O
so	O
as	O
to	O
limit	O
round-off	B-Algorithm
error	I-Algorithm
.	O
</s>
<s>
In	O
the	O
figure	O
,	O
Excel	B-Application
is	O
used	O
to	O
find	O
the	O
smallest	O
root	O
of	O
the	O
quadratic	O
equation	O
x2+bx+c	O
=	O
0	O
for	O
c	O
=	O
4	O
andc	O
=	O
4×105	O
.	O
</s>
<s>
However	O
,	O
beyond	O
some	O
b-value	O
the	O
difference	O
increases	O
because	O
the	O
quadratic	O
formula	O
(	O
good	O
for	O
smaller	O
b-values	O
)	O
becomes	O
worse	O
due	O
to	O
round-off	B-Algorithm
,	O
while	O
the	O
widely	O
spaced	O
root	O
method	O
(	O
good	O
for	O
large	O
b-values	O
)	O
continues	O
to	O
improve	O
.	O
</s>
<s>
At	O
large	O
b-values	O
,	O
the	O
upward	O
sloping	O
curve	O
is	O
Excel	B-Application
's	O
round-off	B-Algorithm
error	I-Algorithm
in	O
the	O
quadratic	O
formula	O
,	O
whose	O
erratic	O
behavior	O
causes	O
the	O
curves	O
to	O
squiggle	O
.	O
</s>
<s>
A	O
different	O
field	O
where	O
accuracy	O
is	O
an	O
issue	O
is	O
the	O
area	O
of	O
numerical	B-Algorithm
computing	I-Algorithm
of	I-Algorithm
integrals	I-Algorithm
and	O
the	O
solution	B-Algorithm
of	I-Algorithm
differential	I-Algorithm
equations	I-Algorithm
.	O
</s>
<s>
Examples	O
are	O
Simpson	B-Algorithm
's	I-Algorithm
rule	I-Algorithm
,	O
the	B-Algorithm
Runge	I-Algorithm
–	I-Algorithm
Kutta	I-Algorithm
method	I-Algorithm
,	O
and	O
the	O
Numerov	O
algorithm	O
for	O
the	O
Schrödinger	O
equation	O
.	O
</s>
<s>
Using	O
Visual	B-Language
Basic	I-Language
for	I-Language
Applications	I-Language
,	O
any	O
of	O
these	O
methods	O
can	O
be	O
implemented	O
in	O
Excel	B-Application
.	O
</s>
<s>
If	O
the	O
grid	O
is	O
spaced	O
very	O
finely	O
,	O
round-off	B-Algorithm
error	I-Algorithm
will	O
occur	O
,	O
and	O
the	O
less	O
the	O
precision	B-Architecture
used	O
,	O
the	O
worse	O
the	O
round-off	B-Algorithm
error	I-Algorithm
.	O
</s>
<s>
Although	O
Excel	B-Application
nominally	O
works	O
with	O
8-byte	B-Application
numbers	O
by	O
default	O
,	O
VBA	B-Language
has	O
a	O
variety	O
of	O
data	O
types	O
.	O
</s>
<s>
The	O
Double	O
data	O
type	O
is	O
8	O
bytes	B-Application
,	O
the	O
Integer	O
data	O
type	O
is	O
2	O
bytes	B-Application
,	O
and	O
the	O
general	O
purpose	O
16	O
byte	B-Application
Variant	O
data	O
type	O
can	O
be	O
converted	O
to	O
a	O
12	O
byte	B-Application
Decimal	O
data	O
type	O
using	O
the	O
VBA	B-Language
conversion	O
function	O
CDec	O
.	O
</s>
<s>
Choice	O
of	O
variable	O
types	O
in	O
a	O
VBA	B-Language
calculation	O
involves	O
consideration	O
of	O
storage	O
requirements	O
,	O
accuracy	O
and	O
speed	O
.	O
</s>
