X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftextwriter.cpp;h=f37b7339e462f35f1cc5461c60dbb60a8a8a3b4b;hb=b39ce68f12c30eedb272b65fe78baec5864d89ca;hp=c870ba0c20d7888f19725761924171c6b01662d9;hpb=cac0716e8c12088ba833cb28809f5a7b8430a68d;p=libs%2Fdatafile.git diff --git a/source/textwriter.cpp b/source/textwriter.cpp index c870ba0..f37b733 100644 --- a/source/textwriter.cpp +++ b/source/textwriter.cpp @@ -10,13 +10,14 @@ namespace Msp { namespace DataFile { TextWriter::TextWriter(Output &o): - WriterMode(o), - float_format("%#.7g") -{ } + WriterMode(o) +{ + float_format.showpoint().precision(7); +} void TextWriter::set_float_precision(unsigned fp) { - float_format = format("%%#.%dg", fp/4-1); + float_format.precision(fp/4-1); } void TextWriter::write(const Statement &st) @@ -39,7 +40,7 @@ void TextWriter::write_(const Statement &st, unsigned level) else if(i->get_signature()==IntType::signature) out.write(lexical_cast(i->get())); else if(i->get_signature()==FloatType::signature) - out.write(format(float_format, i->get())); + out.write(lexical_cast(i->get(), float_format)); else if(i->get_signature()==SymbolType::signature) { string name = i->get().name;