majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Please add fixed or scientific formatting featrure for double values in emitting. #242

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. The following code reproduces it.

#include <iostream>
#include <iomanip>
#include <yaml-cpp/yaml.h>
int main()
{
    YAML::Emitter out;
    double x=10.0;
    double y=10.0;
    double z=0.0;
    out << YAML::Flow << YAML::BeginSeq  << x << y << z << YAML::EndSeq;
    std::cout << out.c_str() << std::endl; // yields [10, 10, 0].

    std::cout <<std::fixed<<std::setw(10)<< "[" << x << ", " << y << ", " << z <<"]"<< std::endl; // output is [10.000000, 10.000000, 0.000000]
    std::cout <<std::scientific<<std::setw(10)<< "[" << x << ", " << y << ", " << z <<"]"<< std::endl; // ditto [1.000000e+001, 1.000000e+001, 0.000000e+000]
}

What is the expected output? What do you see instead?
I wanted fixed or scientific formatting like std::cout can do it 
instead of emitting [10, 10, 0].

What version of the product are you using? On what operating system?
yaml-cpp 0.5.1 on Windows 8.1 Pro.

Please provide any additional information below.
None.

Original issue reported on code.google.com by textdire...@gmail.com on 1 Apr 2014 at 2:10

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 1 Apr 2014 at 2:26

GoogleCodeExporter commented 9 years ago
Thi sissue has moved to github: https://github.com/jbeder/yaml-cpp/issues/242

Original comment by jbe...@gmail.com on 1 Apr 2015 at 3:26