Skip to content

Commit ae70ed0

Browse files
abrockdstahlke
authored andcommitted
Increase output precision of file1d (dstahlke#11)
* Increase output precision of file1d I noticed that sending floating point values through file1d leads to data files where the numbers have 6 digits or less. I send raw data through file1d and then plot differences where the raw values are roughly in the range [1000:6000] and the differences are in the range [0:1] which leads to loss of precision. I did a quick hack to fix it so I can continue using it the way I do, it would probably be cleaner to somehow let the user choose the precision via an optional argument. * Use 17 digits and std::scientific for data output
1 parent 95f9502 commit ae70ed0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gnuplot-iostream.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ class Gnuplot :
15991599
tmp_files(),
16001600
debug_messages(false)
16011601
{
1602-
*this << std::scientific << std::setprecision(18); // refer <iomanip>
1602+
*this << std::scientific << std::setprecision(17); // refer <iomanip>
16031603
}
16041604

16051605
explicit Gnuplot(FILE *_fh) :
@@ -1616,7 +1616,7 @@ class Gnuplot :
16161616
tmp_files(),
16171617
debug_messages(false)
16181618
{
1619-
*this << std::scientific << std::setprecision(18); // refer <iomanip>
1619+
*this << std::scientific << std::setprecision(17); // refer <iomanip>
16201620
}
16211621

16221622
private:
@@ -1711,6 +1711,7 @@ class Gnuplot :
17111711
std::string file(const T &arg, std::string filename, OrganizationMode) {
17121712
if(filename.empty()) filename = make_tmpfile();
17131713
std::fstream tmp_stream(filename.c_str(), std::fstream::out);
1714+
tmp_stream << std::scientific << std::setprecision(17);
17141715
top_level_array_sender(tmp_stream, arg, OrganizationMode(), ModeText());
17151716
tmp_stream.close();
17161717

0 commit comments

Comments
 (0)