<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 - Simplify uses of sal_math_Double"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=137670">137670</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Simplify uses of sal_math_Double
</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>Keywords</th>
<td>difficultyBeginner, easyHack, skillCpp
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>LibreOffice
</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>sbergman@redhat.com
</td>
</tr></table>
<p>
<div>
<pre>We have a helper union sal_math_Double (defined in include/sal/mathconf.h) to
help low-level access to double parts. In several places, double values are
reinterpret_cast to it, to access parts of the IEEE 754 structure. E.g., in
sc/source/core/tool/interpr6.cxx:
<span class="quote">> sal_uInt32 nErr = reinterpret_cast< sal_math_Double * >(&aRes.mfFirst)->nan_parts.fraction_lo;</span >
mathconf.h could define a helper function to make it simpler, which could take
a reference to double, and return it cast to reference to sal_math_Double, so
the above code could be re-written to something like
<span class="quote">> sal_uInt32 nErr = sal_math_DoubleParts(aRes.mfFirst).nan_parts.fraction_lo;</span >
Besides shorter form, the actual benefit is decreased use of unsafe
reinterpret_cast, thus providing better type safety.
To use references in the C header, of course, the function must be enclosed in
the "#if defined __cplusplus" block; or be defined in another helper header.
Alternatively, it should take and return pointers (less ideal IMO).
So the task is to implement such a function, and replace existing cases of
reinterpret_casts of doubles to the struct with use of this function.</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>