X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftextwriter.cpp;h=f37b7339e462f35f1cc5461c60dbb60a8a8a3b4b;hb=b39ce68f12c30eedb272b65fe78baec5864d89ca;hp=5212c9760488330de78807ab7e4eb97bc3727827;hpb=8e3fad222e174b7c659fd3d994d54314657ed989;p=libs%2Fdatafile.git diff --git a/source/textwriter.cpp b/source/textwriter.cpp index 5212c97..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) @@ -37,9 +38,9 @@ void TextWriter::write_(const Statement &st, unsigned level) else if(i->get_signature()==BoolType::signature) out.write(i->get() ? "true" : "false"); else if(i->get_signature()==IntType::signature) - out.write(lexical_cast(i->get())); + 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;