<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - ImpSvNumberInputScan::StringToDouble may produce inaccurate result"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=130725">130725</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ImpSvNumberInputScan::StringToDouble may produce inaccurate result
</td>
</tr>
<tr>
<th>Product</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>UNCONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>Calc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>libreoffice-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mikekaganski@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>erack@redhat.com
</td>
</tr></table>
<p>
<div>
<pre>In Calc, put "0.0042" to A1, "0.0043" to A2, "=A2-A1" to A3; make sure to see
19 decimal places in A3.
Expected result:
<span class="quote">> 0.0001000000000000000</span >
Actual result:
<span class="quote">> 0.0000999999999999994</span >
The problem here is the entered string in A1 has been converted to double
0.0042000000000000006, which is not the nearest double-precision value for
decimal "0.0042": 0.0041999999999999997 is. The conversion of the entered
string to double happens in ImpSvNumberInputScan::StringToDouble, which handles
integer and fractional parts of the string separately, and then multiplies the
fractional part by a power 10 exponent. As shown, this does not guarantee the
closest possible representation, resulting in immediately observable
inaccuracies in following calculations.
A robust conversion is needed here.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>