Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • $\begingroup$ This and this might be of interest for you. $\endgroup$ Commented May 14, 2018 at 18:53
  • $\begingroup$ Alexey, I just edited the C++ code. It works now without precision loss. Have a try. $\endgroup$ Commented May 14, 2018 at 19:41
  • 1
    $\begingroup$ @HenrikSchumacher Thank you for your efforts. The method from the first link produces much more correct output than the method from my question if we increase the precision to 17, but in this case it produces also redundant digits due to the binary representation. I've found that we can get the same result (but 20% faster) if we increase the precision of the original numbers to 17 before exporting with the method from my question. I'll try the C++ solution when I install the compiler. $\endgroup$ Commented May 14, 2018 at 23:47
  • $\begingroup$ It looks like Export to "Table" merely applies ToString[#, InputForm]& to every number in the table for conversion into a string. So one workaround is the following change: WriteString[str,Row[InputForm[#,NumberMarks->False]&/@#,"\t"],"\n"]&~Scan~dat, but it is 10 times slower than the DecimalForm method (and 2 times faster than Export). $\endgroup$ Commented May 15, 2018 at 0:41
  • 1
    $\begingroup$ I don't have DecimalForm in version 10.1. Do you find any use in converting ToString en masse and post processing? Something like StringReplace[ ToString[dat, InputForm, PageWidth -> ∞], {", " -> "\t", "{" -> "\n", "}" -> ""}] $\endgroup$ Commented May 24, 2018 at 0:47