<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 - Implement Ryu float-to-text algorithm (at least for non-locale-dependent cases)"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=131163">131163</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Implement Ryu float-to-text algorithm (at least for non-locale-dependent cases)
          </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>enhancement
          </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></table>
      <p>
        <div>
        <pre>We use O(U)String::number() rather extensively to produce locale-independent
numeric representation, e.g. when saving files. It uses
rtl_math_doubleTo(U)String, which in turn uses our own algorithm in
doubleToString (see sal/rtl/math.cxx).

First thing to note with the said algorithm produces values that don't
round-trip reliably. Then, the performance of it (using multiple floating-point
divisions) could be sub-optimal.

There's a Ryu algorithm [1] to produce unformatted locale-independent
reliably-roundtripping shortest possible (in terms of output decimal places)
strings from floating-point values, that is currently considered the fastest;
it is said to out-perform best previous algorithms not by tens of percents, but
by factor of 5x-20x. It was recently used in implementation of std::to_chars,
and suggested for libc++ [2].

However, the function isn't yet available in both clang and gcc (and it will
take time until the baseline versions of those will include that). Also we
could want to tweak the code to work directly on UTF-16 buffers to avoid
overhead; to have Ryu-printf automatically stripping trailing zeros, etc.

So the task is to implement the algorithm in core, for use in cases where we
produce numbers not intended for display (or maybe even for those cases?
shortest possible should mean they would be rounded towards the neater
alternative?)

[1] <a href="https://github.com/ulfjack/ryu">https://github.com/ulfjack/ryu</a>
[2] <a href="https://reviews.llvm.org/D70631">https://reviews.llvm.org/D70631</a></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>