<div dir="auto">Sometimes it us good to see the ascii values.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 1, 2018 2:31 PM, "Todd via vtk-developers" <<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hi Andras<div dir="auto"><br></div><div dir="auto">I wasn't suggesting base64 encoding the whole file. Just the double/float values.</div></div><div class="elided-text"><div class="gmail_extra"><br><div class="gmail_quote">On 2 Mar 2018 11:19 a.m., Andras Lasso <<a href="mailto:lasso@queensu.ca" target="_blank">lasso@queensu.ca</a>> wrote:<br type="attribution"><blockquote class="m_8288303842807861291quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div style="font-family:'calibri','arial','helvetica',sans-serif;font-size:12pt;line-height:1.3;color:#1f497d">
Base64 encoding is often not feasible or desirable. Usually you don't have the option to change a standard file format (metaimage, nrrd image file headers, ASCII STL files, CSV files, etc.).<br>
<div><br>
</div>
<div style="font-family:'calibri','arial','helvetica',sans-serif;font-size:12pt;color:#1f497d">
Andras<br>
<br>
</div>
</div>
<hr style="border:none;height:1px;color:#e1e1e1;background-color:#e1e1e1">
<div style="border:none;padding:3pt 0cm 0cm 0cm"><span style="font-size:11pt;font-family:'calibri','arial','helvetica',sans-serif"><b>From:</b> Todd via vtk-developers <<a href="mailto:vtk-developers@vtk.org" target="_blank">vtk-developers@vtk.org</a>><br>
<b>Sent:</b> Thursday, March 1, 2018 5:05 PM<br>
<b>To:</b> David Gobbi; <a href="mailto:vtk-developers@vtk.org" target="_blank">vtk-developers@vtk.org</a><br>
<b>Subject:</b> Re: [vtk-developers] Call for Comments: Ascii representation of floats and doubles in files<br>
</span></div>
<br>
<div>
<div dir="auto">
<div dir="auto">Can this not be simply achieved by base64 encoding the value as bytes and saving as a string?  Isn't a float always 10 bytes? </div>
<div dir="auto"><br>
</div>
<div dir="auto">It is more verbose, but there would be no loss of precision. It looks like VTK already has base64 utilities, so another library would not be needed.</div>
<div><br>
<div>On 2 Mar 2018 5:32 a.m., David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<br>
<blockquote style="margin:0 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><br>
<div>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 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://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgoogle%2Fdouble-conversion&data=02%7C01%7Classo%40queensu.ca%7Ce246e174a2d646ebb8ef08d57fc091ff%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636555387414799974&sdata=HtBoj1m03YEF6JixOrvANeIAnZuStEPxWCevD0%2FuAps%3D&reserved=0" 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>
<br>
</div>
</div>
</div>
</div>
</blockquote></div><br></div></div><br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtk-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtk-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://vtk.org/mailman/listinfo/vtk-developers" rel="noreferrer" target="_blank">https://vtk.org/mailman/<wbr>listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><br></div>