<div dir="auto">The library is very small.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 1, 2018 8:33 AM, "David Gobbi" <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I agree that floats should be printed so that conversion is lossless.<div>Python's console output does this and I find it incredibly useful.</div><div><br><div>Not sure if we need to add a new third-party library for this, though,</div><div>especially one that duplicates so much of C++'s built-in machinery.</div><div>Isn't it just a matter of printing enough digits? That's basically what</div><div>I do in my own code (plus checks for isnan(x) and isinf(x), and a</div><div>check of the size of fabs(x) for whether to force scientific notation.)</div><div><br></div><div> - David</div><div><br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 1, 2018 at 8:48 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Will,<br>
<br>
It would go in Common/Core I think. The vtk class would be very small.<br>
<br>
Bill<br>
<br>
On Thu, Mar 1, 2018 at 7:36 AM, Will Schroeder<br>
<<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a>> wrote:<br>
> If it works why mess with success? Where would this class<br>
> (vtkNumberToString) be placed, in Common/Core (like vtkIndent) or in some IO<br>
> directory like VTK/IO/Core?<br>
><br>
> On Thu, Mar 1, 2018 at 10:06 AM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Folks,<br>
>><br>
>> I'm working on some examples to save/restore camera, polydata,<br>
>> property, etc. in XML files. The files can be saved as binary or<br>
>> ascii. If I save/restore the info in binary, I get the same values for<br>
>> the saved info. But, to no surprise, when I save the same data in<br>
>> ascii, I don't get the same values. This is because the file writing<br>
>> code does not write enough significant digits.<br>
>><br>
>> In ITK we solved this problem many years ago. ITK uses a reduced<br>
>> version of the Google double-conversion library,<br>
>> <a href="https://github.com/google/double-conversion" rel="noreferrer" target="_blank">https://github.com/google/doub<wbr>le-conversion</a>.<br>
>><br>
>> We added a small class to ITK that uses the library. The class,<br>
>> itkNumberToString, has a simple API. To convert floating and fixed<br>
>> point numbers to ascii without numerical precision erros,<br>
>><br>
>> For example, to convert a float,<br>
>> #include "itkNumberToString.h:<br>
>> itk::NumberToString<float> convert;<br>
>> float a = 1.0f/3.0f;<br>
>> std::cout << convert(a) << std::endl;<br>
>><br>
>> I propose a similar approach in VTK.<br>
>><br>
>> Comments please,<br>
>><br>
>> Bill<br></blockquote></div></div></div></div></div></div>
</blockquote></div></div>