<html>
<head>
<base href="https://bugs.documentfoundation.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Accuracy of calculation in Fill"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=90419#c5">Comment # 5</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Accuracy of calculation in Fill"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=90419">bug 90419</a>
from <span class="vcard"><a class="email" href="mailto:piet@vanoostrum.org" title="Piet van Oostrum <piet@vanoostrum.org>"> <span class="fn">Piet van Oostrum</span></a>
</span></b>
<pre>(In reply to Eike Rathke from <a href="show_bug.cgi?id=90419#c1">comment #1</a>)
<span class="quote">> While generally all floating point numbers that are not exactly
> representable in an IEEE 754 double lose precision, this specific case of
> filling a series of numbers could be improved by using multiplication
> instead of incrementing (adding delta) values.</span >
Actually, this is already how it is done.
In ScTable::FillSeries:
case FILL_LINEAR:
{
// use multiplication instead of repeated addition
// to avoid accumulating rounding errors
nVal = nStartVal;
double nAdd = nStepValue;
if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
!SubTotal::SafePlus( nVal, nAdd ) )
bError = true;
}
However, depending on the initial values, this may still give rise to
"unexpected" values (that is unexpected with regard to the "intuitive"
expectations). But that's life with floating point numbers.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>